Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 222 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
share|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
9  
just found out that :so $MYVIMRC also works –  ivo Apr 17 '10 at 15:16
3  
and :so ~/.vimrc should work too on unix –  Yab May 8 '11 at 18:18
2  
:so ~/_vimrc works on windows. Of course, I keep my _vimrc in my windows home directory, or else this won't work. To see what Vim considers your home directory, use :echo expand("~"). –  Daniel Miladinov Nov 30 '12 at 14:10

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.

share|improve this answer
    
Very useful, thanks! –  jco Jul 4 '13 at 21:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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