0

I'm just so sick of typing source ~/.vimrc all the time, for entering the "~/.vimrc" I have to move my fingers a lot. Is there a way that I could map ~/.vimrc into a single letter or a sign. For example source % instead of source ~/.vimrc

AkA I would like to use % to represent ~/.vimrc

Thanks

3
  • 2
    As it appends % refers to the file currently being edited in vim. So if you're editing ~/.vimrc, :source % will source it. – Stéphane Chazelas Jan 11 '18 at 15:42
  • 1
    At a shell prompt, or within vim? – Jeff Schaller Jan 11 '18 at 15:46
  • @JeffSchaller within vim Thanks for point that out! – SLN Jan 11 '18 at 15:52
1

:abbreviate

:ab % ~/.vimrc

I would recommend you to use another character in stead of %

1

The accepted answer is good. A few "enhancements"...

The Vim environment variable $MYVIMRC contains the path to whatever file was actually sourced as your vimrc so it's a convenient and portable way to express ~/.vimrc...might want to use that in the abbreviation.

If you're really sick of typing then you could avoid :source, too (not counting the fact that you only have to type :so):

nnoremap <C-S> :so $MYVRIMC<CR>

With this you can load your vimrc by hitting Ctrl+S and you don't even have to leave Normal mode. (<C-S> is an example...replace it with whatever unused key(s) you want.)

1
  • @B Layer awesome! – SLN Jan 11 '18 at 21:28

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.