How do I move between split windows using direction keys in Vim?
Answer
<C-w>h / <C-w>j / <C-w>k / <C-w>l
Explanation
How it works
Vim lets you navigate between split windows using <C-w> followed by a direction key. The direction keys match the standard hjkl movement keys:
<C-w>hmoves to the window on the left<C-w>jmoves to the window below<C-w>kmoves to the window above<C-w>lmoves to the window on the right
This is more precise than <C-w><C-w>, which just cycles through windows in order. With directional navigation, you can jump directly to the window you want based on its position.
Example
Suppose you have a layout with four windows arranged in a grid:
+--------+--------+
| File A | File B |
+--------+--------+
| File C | File D |
+--------+--------+
If your cursor is in File A:
<C-w>ljumps to File B (right)<C-w>jjumps to File C (below)
If your cursor is in File D:
<C-w>hjumps to File C (left)<C-w>kjumps to File B (above)
Many Vim users remap these for faster access by adding to their 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
This lets you press Ctrl-h instead of Ctrl-w h, saving one keystroke each time you switch windows.