Info

Hi, I'm David Askew

I build things

Homepage

Contact Me

About

Open Source

Keyboard Foo - VIM Edition

As a new vim user, I’m constantly openning up my ~/.vimrc file to tweak one thing or another.

There really isn’t a lot of keystrokes necessary to it the manual way:

:e ~/.vimrc

I don’t care how short the normal way is. It could be easier. I’d prefer to be able to type the following key combo in normal mode:

,
v

Here’s what you put in your configuration to make that happen, assuming your “leader” key is set to “,”:

nmap <leader>v :tabedit $MYVIMRC<CR>

If you want your current VIM session to update automatically with the changes you just made via the new shortcut, then add the following:

if has("autocmd")
   autocmd bufwritepost .vimrc source $MYVIMRC
endif

Anytime you save your ~/.vimrc file, it will now update your current config.

If you don’t want to do it the magical way, then you need to remember to execute the following command when you save your config:

:source $MYVIMRC

I hope this helps!