Most edits are operator + motion:
| Operator | Does |
|---|---|
d |
delete |
c |
change (delete, then insert) |
y |
yank (copy) |
dw deletes a word, c$ changes to the end of the line, y2j yanks three
lines. Doubling an operator acts on whole lines: dd, cc, yy. Shortcuts:
D = d$, C = c$, x = dl, s = cl.
p puts after the cursor (below, for lines); P before.
Counts go before the command or the motion: 3dw = d3w.
The dot command
. repeats the last change — including everything you typed in insert mode.
Make a change once, move, press .. It's the single most useful key in Vim.
cwfoo<Esc> change a word to foo
w. next word: change it too