nerdexam
CompTIA

LX0-103 · Question #199

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?

The correct answer is B. By specifying the number right in front of a command such as 4l or 2yj.. In vi, prefixing a command with a number causes that command to execute the specified number of times or act on that many lines.

GNU and Unix Commands

Question

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?

Options

  • ABy using the command :repeat followed by the number and the command.
  • BBy specifying the number right in front of a command such as 4l or 2yj.
  • CBy selecting all affected lines using the shift and cursor keys before applying the command.
  • DBy issuing a command such as :set repetition=4 which repeats every subsequent command 4

How the community answered

(26 responses)
  • A
    4% (1)
  • B
    92% (24)
  • D
    4% (1)

Why each option

In vi, prefixing a command with a number causes that command to execute the specified number of times or act on that many lines.

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

vi has no built-in :repeat command; this is not valid vi/ex syntax.

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

vi accepts an optional numeric count directly before most normal-mode commands to repeat them. For example, 4l moves the cursor four characters to the right, and 2yj yanks the current line plus the next line into the buffer. This count prefix is a core part of vi's command syntax and applies to motion, editing, and yank commands.

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

vi does not support selection via Shift and cursor keys for command application; that interaction model belongs to modern GUI editors or vim visual mode.

DBy issuing a command such as :set repetition=4 which repeats every subsequent command 4

There is no :set repetition setting in vi; no such configuration option exists in the vi/ex command set.

Concept tested: vi numeric count prefix for command repetition

Source: https://linux.die.net/man/1/vi

Topics

#vi editor#command repetition#numeric prefix

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice