~ / operators
3
Operators & the Dot
Vim's grammar: an operator (d, c, y, gU, >…) plus a motion. Learn to make changes that repeat with a single ..
- 01
Operator + motion: d, c and y
Vim edits are sentences: a verb (the operator) and how far (the motion).
d{motion}c{motion}y{motion}dwdedbd$d0 - 02
Line shortcuts: dd, cc, D, C, J and friends
Doubled operators act on whole lines; capitals run to the end of the line.
ddccyyDCYxXnvim - 03
Put, undo and redo: p, P, u and <C-r>
Deleted text is cut, not lost. Put it back anywhere, and undo freely.
pPu<C-r>xpddpyyp - 04
The dot command: repeat the last change
Make a change once, then move and press . to do it again.
.{count}.f{char};A - 05
Rename one at a time: *, n and cgn
Search for a word, change it once, then repeat at each match you choose.
*#nNcgndgn{Visual}*nvim - 06
Counts: do it N times
A number before a command repeats it, and <C-a> / <C-x> do arithmetic.
{count}{cmd}3dwd3w3p<C-a><C-x>nvim - 07
Case, indent and replace: gU, gu, >, < and r
More operators for any motion, plus one-character fixes with ~ and r.
gU{motion}gu{motion}g~{motion}gUU>{motion}<{motion}>>={motion}