Solaris Advanced User's Guide

Using a Count to Repeat Commands

Many vi commands can be preceded by a repeat factor (called a count)—a number that precedes the command and tells it how many times to repeat the operation.

Most of the commands in the previous sections take counts. For instance, 3dd repeats the command to delete a line three times, therefore deleting three lines. 2dw deletes two words, and 4x deletes four characters or spaces. You can also use counts with commands to move the cursor, such as 3w and 2Ctrl-F. In the section Summary of Basic vi Commands each command that takes a count is indicated by “[count]” before the command name.

Typing a period (.) repeats the previous text-changing command. For example, if you have just deleted a line with dd, you can move the cursor to another line and delete it by simply typing a period.