Repeating the same operation multiple times is inefficient. Manual replication wastes time and introduces inconsistency.
Two repetition mechanisms: the dot command (.) repeats the last change; numeric prefixes repeat commands N times.
- Repeats the last Simple change
- Examples:
100idesu [ESC]writes “desu” 100 times.repeats that 100 “desu”3.repeats 3 times (300 total, not 300!)
- A Simple change = one command that makes one change
- Precedes any command with a count
- Examples:
2dd— delete 2 lines3p— paste 3 times5 dw— delete 5 words10j— move down 10 lines
.only repeats simple changes, not complex sequences- Numeric counts are multiplied, not added:
3.× 3 = 9 not 6 - Operator + motion = repeat-able command:
d2wis one command uundo is itself undo-able
.doesn’t repeat Ex commands (:s/...).after.compounds:2.= 6 total- Search/replace needs
:s///&or&to repeat
- Survival Commands —
ddandpare repeatable - Vim Modes — Repetition works in Normal mode
- Navigation —
Nprefix repeats search - Macros — More complex repetition with recording