I'm just getting into Vim, and, as one might expect, I'm constantly adding things to my .vimrc. At the moment i'm using :tabe ~/.vimrc and I was just curious if there was a quicker command for getting to the.vimrc that was used when Vim launched.

  • 2
    Not quicker, but thought you should know, :e $MYVIMRC. And, many people create a keybinding for editing their vimrc. You could also do that, especially if you're at the beginning of your vim journey and constantly editing your vimrc. – klaus Sep 26 '19 at 4:50
  • With tabcompletion :e $MYV<Tab><CR>. However, I would certainly recommend using the uppercase mark 'V for this as Matt showed in his answer. – Hotschke Sep 26 '19 at 11:23

You could use $MYVIMRC. See :help .vimrc. It says:

The $MYVIMRC environment variable is set to the file that was first found, unless $MYVIMRC was already set and when using VIMINIT.

$MYVIMRC is also not set if you use the command line option -u to specify a different ini file.

I have two mappings in my vimrc:

noremap _v :e $MYVIMRC<CR>
noremap _u :source $MYVIMRC<CR>

By hitting _v I can open my vimrc and with _u the vimrc is reloaded.


Another way is to use a bookmark.

That is, while .vimrcis open, press mV to save current position in a global bookmark 'V'. To reopen .vimrc in the current window simply go to the bookmark with 'V.

The "capital letters" bookmarks are automatically saved in viminfo, so they will persist between sessions. Also, there are 26 such bookmarks, so you can easily track a couple of other important files, not just .vimrc.

  • 1
    +1 It took me an embarrassingly long time to discover how useful uppercase marks are for this sort of thing. (Literally years.) Sidenote: if there are 26 bookmarks, you can track up to 25 other files, not just a couple! ;) – Rich Sep 26 '19 at 8:18
  • @Rich Well, it took me significantly less time, though I didn't discover it myself, but saw this advice somewhere ;-) – Matt Sep 26 '19 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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