level 05
Quick Editing
x, r, s, J, p, undo/redo, and the mighty dot command.
A grab bag of small, sharp tools: fix a single character, join two lines, paste what you cut, walk your undo history. And one command that outshines them all, hiding behind a single key: the dot. . repeats your last change, and once it’s in your hands you’ll feel naked editing without it.
Single-Character Operations
x X → delete character under / before the cursor
r → replace one character (ra → 'a')
s → substitute character (delete + Insert mode)
~ → toggle case
J gJ → join line below (with / without a space)
Copy, Paste, Undo
yy p P → yank line, paste after / before
u → undo
Ctrl+r → redo
Note: d, dd, c all cut to the default register, deleting is cutting, so you can always paste what you removed.
The Dot Command
. → repeat the last change
The move that defines fluent Vim: search with /name, change one match with ciw + new text + Esc, then bounce n . n . down the file. Each n finds the next hit, each . re-runs the edit. It turns “rename this in twelve places” into a drum beat. Learn this one pattern and you’ve learned why people refuse to leave.
Single-character fixes
Thiss: cursor on the extras, pressx.sentense: cursor on the wrongs(the one before the laste), pressrthencto make itsentence.itt: cursor on the extrat, pressx.foxe: cursor on thee, pressx.ovverandlazzy: cursor on the doubled letter, pressx.
goal Use r to substitute and x to delete without entering Insert mode.
Join lines
- On
const message =, pressJ: joins the next line with a space. - On
const items = [, pressJa few times to collapse the array onto one line. - Undo, then try
gJinstead: no space is added.
goal J adds a space, gJ does not.
The dot command
- On the first
getValue, pressciw, typefetchData, pressEsc. - Press
jto move to the next line. - Press
.to repeat the change. - Continue
jthen.down the rest.
goal Make one change, then j + . to repeat it on identical targets.
The n + . rhythm
- Type
/console.logand Enter. - Press
ct(, typelogger.info, pressEsc. Whyct(and notcw?cwstops at the., leaving.logbehind;ct(changes everything up to the(. - Press
nfor the next match, then.to repeat. - Continue
n.n.n.through all of them: same edit, four keystrokes.
goal Search, change once, then n and . through every occurrence.
Undo / redo
- Make three changes:
1→2,"app"→"myapp","Alice"→"Bob". - Press
uthree times: each change reverts in turn. - Press
Ctrl+rto redo them back, one at a time.
goal Undo and redo step through each individual change.