Counts

Type a number before any motion or operator. It multiplies.

Keys: {n}

Most Vim commands accept a count prefix. 5j moves down 5 lines. 3dw deletes 3 words. Counts on both sides of an operator multiply.

Almost every Vim command accepts a numeric prefix. The number means "do this N times." That's it โ€” no escape sequence, no special key. Just type the digits, then the command.

Move down 5 lines
KeyNote
5
j
Delete 10 characters
KeyNote
1
0
x
Delete 3 words
KeyNote
3
d
w
Counts on motions
Counts on edits
Counts before operators
Counts on insert

Reference

Pattern Means
{n}{motion} Apply motion n times
{n}{op}{motion} Apply (op + motion) n times
{op}{n}{motion} Apply op once over (motion ร— n)
{n}{op}{m}{motion} Apply op (n ร— m) times over motion
{n}. Repeat last change with new count n

Worked example โ€” 5j and 3dw

Counts multiply motions and operators.

Step 1 ยท
counts.basics
Step 2 ยท 5j ยท 5j โ€” down five lines.
5j โ€” down five lines.
Step 3 ยท gg 3dw ยท 3dw โ€” three words gone (next demo).
3dw โ€” three words gone (next demo).
Step 4 ยท 3dw ยท On 'the quick brown fox jumps', 3dw deletes the first three words.
On 'the quick brown fox jumps', 3dw deletes the first three words.

Counts apply equally to motions and to operator+motion combos. 3dw == d3w == ddwdwdw.

โ–ถ Try this in the simulator

See also: The Universal Grammar, Delete, Dot with Counts