How do I insert the same text multiple times without a macro or copy-paste?
Answer
80i-<Esc>
Explanation
Vim's insert commands accept a count prefix that repeats everything you type. When you press <Esc> to leave insert mode, Vim duplicates the inserted text the specified number of times. This is a fast way to create separator lines, repeated strings, or padding without reaching for macros or external tools.
How it works
80— the count prefix, specifying how many times to repeati— enter insert mode (also works witha,o,O, etc.)-— type whatever characters you want repeated<Esc>— exit insert mode; Vim repeats the inserted text 80 times total
Example
To create a horizontal rule of 40 equals signs:
Before:
Section Title
(cursor on line below)
Type: 40i=<Esc>
After:
Section Title
========================================
This also works with multi-character insertions:
Type: 5iha <Esc>
Result: ha ha ha ha ha
Tips
- Works with
a(append),o(open line below), andO(open line above) too —3o<CR><Esc>inserts 3 blank lines - The count applies to the entire inserted text, so
3ifoo<Esc>producesfoofoofoo - Combine with
<C-v>Iin visual block mode: the count applies to every line in the block