How do I use count prefixes to amplify motions and operators in Vim?
Answer
{count}{motion}
Explanation
Almost every Vim motion and operator accepts a numeric count prefix that repeats or amplifies the action. Mastering counts transforms basic motions into precision tools — jumping exactly 5 words, deleting 3 lines, or indenting 2 levels.
How it works
{count}{motion}— repeat the motion count times{count}{operator}{motion}— apply operator over count repetitions- Counts can be used with operators, motions, and even combined
2d3w= delete 6 words (2 × 3w)
Example
5j — move down 5 lines
3w — move forward 3 words
4dd — delete 4 lines
2>> — indent current line 2 levels
10k — move up 10 lines
3p — paste 3 times
Before 3dw:
the quick brown fox jumps
After:
fox jumps
Tips
- Use
:set relativenumberto see exact counts for vertical jumps v3awin visual mode selects 3 words- Some commands interpret count differently:
3Jjoins 3 lines, notJthree times - Combine with repeat:
5.repeats the last change 5 times - In insert mode,
<C-o>5jexecutes a single normal command with count