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

It bothers me when I wrote something into .vimrc and I have to close it first and open to get my changes be applied. Is there a way of reload .vimrc in Vim without closing it?

E.g. I've added set nu to ~/.vimrc and I want line numbers to appear for all my windows and buffers.

share|improve this question
up vote 79 down vote accepted

:source ~/.vimrc

Run that from inside vim, that will apply your .vimrc


:source $MYVIMRC

share|improve this answer
Thank you. This works. – Nemoden May 22 '11 at 8:52

Here's one for posterity. Add the following to your .vimrc:

map <leader>vimrc :tabe ~/.vim/.vimrc<cr>
autocmd bufwritepost .vimrc source $MYVIMRC

The first line means you can open your vimrc from any vim buffer by typing your leader, then writing "vimrc." For example, my leader is set to comma, so if I'm in edit mode and I type ",vimrc" it opens my vimrc in a new tab.

The second line automatically sources the changes to your vimrc when you save and close it. It's magic.

share|improve this answer
Ideally wouldnt you map <leader>vimrc :tabe $MYVIMRC<cr> to match the autocmd? – Nick Bisby Sep 3 '14 at 15:38
@NickBisby For me ~/.vimrc is just a stub that sources ~/.vim/.vimrc so that I can keep everything under source control. For most people you are correct, it would be :tabe $MYVIMRC<cr>. – Dean Sep 3 '14 at 16:45
Alternatively you could use a symbolic link to your actual .vimrc file instead of having it be a stub. – Spoike Apr 19 at 12:14

:so %

if currently editing .vimrc

share|improve this answer

You must log in to answer this question.

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