Can you edit your .vimrc file in vim, and reload it without restarting vim?

link|improve this question
feedback

2 Answers

up vote 40 down vote accepted

If you're editing it, you can reload it with:

:so %

% stands for current file name (see :h current-file) and :so is short for :source, which reads the content of the specified file and treats it as Vim code.

In general, to re-load the currently active .vimrc, use the following (see Daily Vim):

:so $MYVIMRC
link|improve this answer
what's the meaning of this command? – ivo Apr 17 '10 at 14:25
1  
Have a look at stackoverflow.com/questions/803464/… – mrucci Apr 17 '10 at 14:27
4  
just found out that :so $MYVIMRC also works – ivo Apr 17 '10 at 15:16
and :so ~/.vimrc should work too on unix – Yab May 8 '11 at 18:18
feedback

Even better, you configure Vim to watch for changes in your .vimrc and automatically reload the config.

augroup myvimrc
    au!
    au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END

Source: this answer on SO

Note: this particular method watches for the many variations of Vim config filenames so that it's compatible with GUI Vim, Windows Vim, etc.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.