vimtricks.wiki Concise Vim tricks, one at a time.

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>h moves to the window on the left
  • <C-w>j moves to the window below
  • <C-w>k moves to the window above
  • <C-w>l moves 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>l jumps to File B (right)
  • <C-w>j jumps to File C (below)

If your cursor is in File D:

  • <C-w>h jumps to File C (left)
  • <C-w>k jumps 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.

Next

How do you yank a single word into a named register?