navigation
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.
w b e (normal / visual mode) Variations
| Keystroke | Effect |
|---|---|
| W / B / E | Uppercase variants treat WHITESPACE-separated tokens as one word (ignores punctuation) |
| 3w | Move forward 3 words |
| dw | Delete from cursor to start of next word |
| cw | Change (delete + enter insert) to end of word |
Examples
w Move to start of next word
5b Jump 5 words backward
dW Delete whole whitespace-separated token including punctuation
Gotcha
w stops at punctuation (foo.bar is three words); use W to treat the whole thing as one. e lands on the last character, not after it.
Related
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.
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.
dd
Deletes the current line (and stores it in the unnamed register, so you can paste it back with p). The bread-and-butter 'get rid of this line' command.
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.
%
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.