Five Time-Saving Vim Tricks

Benjamin Klein, who wrote The VimL Primer, recently published a blog post entitled Save time in Vim NOW with these five weird tricks. I was looking for one weird trick, so I was very happy to receive five weird tricks. Anyway, one of them is about switching windows with CTRL and then a direction (hjkl), which saves a key press.

This is what the mapping looks like:

noremap <c-j> <c-w>j
noremap <c-k> <c-w>k
noremap <c-l> <c-w>l
noremap <c-h> <c-w>h

I’ve accidentally enabled this before when I’ve tried out .vimrc files from GitHub, or those Vim plugin packs aimed at beginners. For some reason I've never got used to it, I don't know if pressing CTRL and then a key with the right-hand just feels weird to me or what, but I find it tricky.

In the comments, “syath” recommends combining the mappings with Vim Tmux Navigator. This allows you to navigate between Vim and tmux panes… painlessly. It requires tmux version 1.8 or higher, so you might want to update your packages if it doesn’t seem to work.

Like what you read? Give Alex R. Young a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.