Skip to main content
Linux AdministrationMediumSingle Choice

Linux Administration Question

Statement

In the vi editor, how can commands such as moving the cursor or copying lines into the buffer be issued multiple times or applied to multiple rows?

#vi#vim#numeric-prefix#cursor-movement#yank
A

By using the command :repeat followed by the number and the command.

B

By specifying the number right in front of a command such as 4l or 2yj.

Correct
C

By selecting all affected lines using the shift and cursor keys before applying the command.

D

By issuing a command such as :set repetition=4 which repeats every subsequent command 4 times.

Resolution & Explanations

In the vi editor, commands can be repeated or applied to multiple lines by prefixing the command with a number. For example, 4l moves the cursor four characters to the right, and 2yj yanks two lines (the current line and the next) into the buffer. This numeric prefix is a fundamental vi feature that allows efficient repetition of movement, deletion, yanking, and other operations.