tags:

views:

272

answers:

4

I want to edit .vimrc file from Vim and apply them without restarting Vim.

Is that possible?

Thank you.

+3  A: 

source your vimrc file :source ~/.vimrc

shingara
+13  A: 

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.

Raoul Supercopter
Works great, just what I wanted, Thanks
saint
Didn't know this was possible, really well done!
Somebody still uses you MS-DOS
+2  A: 

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.

sirlancelot
I didn't get your command. Where is $MYGVIMRC defined?
Somebody still uses you MS-DOS
It is set when GUI Vim is started. see `:help gvimrc`
sirlancelot
A: 

autocmd! bufwritepost _vimrc source %

this will automatic reload all config in _vimrc file when you save

James