Learn Vim / How to Repeat Your Last Change in Vim (the Dot Command)

How to Repeat Your Last Change in Vim (the Dot Command)

The answerPress . — it replays your last change. Combine with n (next search match) to fix repeated problems fast: /bug, daw, then n . n .

Try it on a real buffer

Three “bug” words infest this file. Search with /bug, delete the first with daw, then press n to jump to the next match and . (dot) to repeat the delete. Clear all three.

The demo worked bug perfectly on my machine.
The tests bug passed on the first try.
Nothing bug suspicious happened at all.

Canonical solution: /bug Enter, daw, n, ., n, . · par: 12 keystrokes (vimgolf rules — every keypress counts).

Why it works

n repeats the last search forward (N goes backward). The dot command . replays your last change. Search + n + . is one of the fastest editing loops in vim.

Variations

KeysWhat it does
.repeat the last change
njump to the next search match
; / ,repeat the last f/t jump forward / backward
@@repeat the last macro

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Exterminator” mission takes about a minute.

Practice free — no signup →

Keep going