Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 454 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):

share|improve this answer
Have a look at… – mrucci Apr 17 '10 at 14:27
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
: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
Note that if keyboard mappings were already in place, then they will not erased even if they are deleted from the new vimrc – Phani Oct 2 '14 at 6:58

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

augroup myvimrc
    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

An alternative to remembering/typing :so $MYVIMRC is these mappings. It lets you quickly edit vimrc (ev) or source vimrc (sv).

" Quickly open/reload vim
nnoremap <leader>ev :split $MYVIMRC<CR>  
nnoremap <leader>sv :source $MYVIMRC<CR>     
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .