navigation
h j k l
The four fundamental cursor keys in Vim: h moves left, j down, k up, l right. Reach for them any time you would instinctively hit an arrow key — keeping your hands on the home row is the whole point.
h j k l (normal / visual mode) Variations
| Keystroke | Effect |
|---|---|
| 10j | Jump 10 lines down (count prefix works on all motions) |
| 5l | Move 5 characters right |
| d3j | Combined with operator: delete current line plus 3 below |
Examples
j Move cursor down one line
20k Jump 20 lines up
y5l Yank 5 characters to the right
Gotcha
These only work in normal or visual mode. In insert mode they type literal letters — press Escape first.
Related
w / b / e
Word motions: w jumps to the start of the next word, b to the start of the previous word, e to the end of the current/next word. These are the fastest way to hop across a line without leaving the home row.
gg / G
gg jumps to the first line of the file; G jumps to the last line. Prefix G with a number to jump to that absolute line — the fastest way to reach a specific line from a stack trace.
Escape
Leaves the current mode and returns to normal mode. Vim is modal — most of the time you want to be in normal mode; if you're not sure what mode you're in, mash Escape.
0 / $
0 jumps to the very first column of the line; $ jumps to the last character. Use ^ (bonus) if you want the first non-blank character instead of column zero.
%
In normal mode, % jumps between matching pairs of (), [], {}, and (with matchit) HTML/XML tags. Indispensable for navigating nested code and confirming that a stray brace really does close where you think it does.