Vim tip 13: repeat last change
It is way too easy to repeat the last change you made:
- . the Normal mode dot command repeats the last change
- you can also use a number prefix to override the count of the last change
For example,
- if the last change was 2dd (delete current line and the line below), dot key will repeat
2dd
- using 3. will mean
3dd
and not6dd
, since the count prefix replaces the earlier number
- using 3. will mean
- if the last change was 5x (delete current character and four characters to the right), dot key will repeat
5x
- if the last change was C123<Esc> and dot key is pressed, it will clear from the current character to the end of the line, insert
123
and go back to Normal mode
From :h 4.3:
The . command works for all changes you make, except for u (undo), CTRL-R (redo) and commands that start with a colon (
:
).
See :h repeat.txt for complex repeats, using Vim scripts, etc.
Video demo:
See also my Vim Reference Guide and curated list of resources for Vim.