vimtricks.wiki Concise Vim tricks, one at a time.

How do I repeat the last change in Vim?

Answer

.

Explanation

The . (dot) command repeats the last change you made. It is one of the most powerful commands in Vim because it lets you apply the same edit multiple times with a single keystroke.

How it works

Any command that modifies the buffer counts as a "change" — including insertions, deletions, replacements, and indentation. After performing a change, pressing . replays that exact change at the current cursor position.

Example

To delete three separate words throughout a file:

  1. Move to the first word, press daw to delete it
  2. Move to the second word, press . to delete it
  3. Move to the third word, press . again

Common use cases

  • Delete the word under the cursor (daw), find the next one (n), repeat (.)
  • Change a variable name with ciw + new name + <Esc>, then . on each occurrence
  • Add a semicolon with A; + <Esc>, then j. to add it to the next line

Tips

  • Combine with search (/pattern then n to find, . to repeat the change) for a manual find-and-replace
  • The dot command includes the full insert mode session — from entering insert mode to pressing <Esc>
  • Counts work too: 3. repeats the last change three times

Next

How do I edit multiple lines at once using multiple cursors in Vim?