Tuesday, March 12, 2013

Move Around Vim Windows Less Annoyingly

On any given project at work, I will always end up opening 3-4 windows (and even more recently, the NERD Tree sidebar, which is a plugin I recommend everyone get) and I get sick of having to press Ctrl+W and then h, j, k or l to move to the next window. It's one of my most used key combinations and it needed to be shortened.

I wanted to just type Ctrl+[hjkl]. So I added this to my .vimrc:

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

And that's it. Easier window navigation with a quick vimrc addition!