12 May 2012

My current favorite VIMRC one-liner

Very handy for quickly swapping between prior file and current file in VIM:

Add the following to VIMRC: nnoremap <leader>, :b#<cr>

My current leader key is set to comma (,) so punching ,, switches between prior and current file, or back again.

Runner up for other good one liners: inoremap jk <esc> This one allows you to stay on the commandline and ESCAPE out of insert mode by using key combo ‘jk’!Note: I find this faster than a more common binding of ‘jj’ for this purpose. With jj the same finger needs to activate the key in quick succession. With j & k the right hand index and middle finger both activate at a similar time. Thus my preference goes to the slightly easier and faster option.

Source & Credit: Gary Bernhardt’s Dotfiles on Github (though escape sequence of jj swapped to j k)

PS - The only conflict I’ve had with j k being an ESC sequence is this blog post. In code and prose I haven’t run into problems.