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

  1. Thiss — cursor on the extra s, press x.
  2. sentense — cursor on the wrong s (the one before the last e), press r then c to make it sentence.
  3. itt — cursor on the extra t, press x.
  4. foxe — cursor on the e, press x.
  5. ovver and lazzy — cursor on the doubled letter, press x.
normalpress i to type · hjkl to move

goal Use r to substitute and x to delete without entering Insert mode.

Join lines

  1. On const message =, press J — joins the next line with a space.
  2. On const items = [, press J a few times to collapse the array onto one line.
  3. Undo, then try gJ instead — no space is added.
normalpress i to type · hjkl to move

goal J adds a space, gJ does not.

The dot command

  1. On the first getValue, press ciw, type fetchData, press Esc.
  2. Press j to move to the next line.
  3. Press . to repeat the change.
  4. Continue j then . down the rest.
normalpress i to type · hjkl to move

goal Make one change, then j + . to repeat it on identical targets.

The n + . rhythm

  1. Type /console.log and Enter.
  2. Press ct(, type logger.info, press Esc. Why ct( and not cw? cw stops at the ., leaving .log behind; ct( changes everything up to the (.
  3. Press n for the next match, then . to repeat.
  4. Continue n.n.n. through all of them — same edit, four keystrokes.
normalpress i to type · hjkl to move

goal Search, change once, then n and . through every occurrence.

Undo / redo

  1. Make three changes: 12, "app""myapp", "Alice""Bob".
  2. Press u three times — each change reverts in turn.
  3. Press Ctrl+r to redo them back, one at a time.
normalpress i to type · hjkl to move

goal Undo and redo step through each individual change.