I want to edit .vimrc file from Vim and apply them without restarting Vim.
Is that possible?
Thank you.
I want to edit .vimrc file from Vim and apply them without restarting Vim.
Is that possible?
Thank you.
Yes, just use the :so %
command while editing your .vimrc.
If you want vim to auto-reload your configuration, you must add the following commands :
augroup myvimrchooks
au!
autocmd bufwritepost .vimrc source ~/.vimrc
augroup END
the grouping of autocommand is here to avoid "exponential" reloading if you save several times your configuration.
Here's a more cross-platform compatible version if you run on Mac/Windows/Linux and gvimrc
:
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
The autocmd watches all potential *vimrc
files and when one changes, it reloads the vimrc
file followed by gvimrc
if the GUI is running.
autocmd! bufwritepost _vimrc source %
this will automatic reload all config in _vimrc file when you save