Step 4 of 6

3. Basic Navigation

Using a count to repeat motions

All the things we’ve learned in the past few sections can be described as ‘motions’. A motion is any command that moves the cursor

Some motions can be supplied with a count, which usually tells Vim how many times to repeat the movement. For example, the j command (for moving the cursor downwards) accepts a count with tells it how many positions to move the cursor. If you type 10j, Vim will move the cursor ten lines down.

Counts work with the character jumps from the last step too: 2fX jumps to the second X on the right, and 2; repeats the last f motion twice.

Work through the checklist below — each motion is a single count-powered stride.

  1. Drop five lines in one motion From the top line (gg takes you back), the line of Xs is five below — type 5j.
  2. Jump to the second X in one go Press ^ to sit at the start of the X line, then type 2fX.
  3. Repeat the jump, twice To repeat the fX motion two more times in a single stride, type 2;.
Drop five lines in one motion From the top line (gg takes you back), the line of Xs is five below — type 5j.

Next: Jump to the second X in one go

Loading editor…