nerdexam
CompTIA

LX0-103 · Question #209

In the vi editor, which of the following commands will copy the current line into the vi buffer?

The correct answer is D. yy. In vi, the yy command yanks (copies) the current line into the unnamed buffer, ready to be pasted with the p or P command.

GNU and Unix Commands

Question

In the vi editor, which of the following commands will copy the current line into the vi buffer?

Options

  • Ac
  • Bcc
  • C1c
  • Dyy
  • E1y

How the community answered

(22 responses)
  • A
    5% (1)
  • D
    95% (21)

Why each option

In vi, the yy command yanks (copies) the current line into the unnamed buffer, ready to be pasted with the p or P command.

Ac

The c command is a change operator that requires a motion argument and switches to insert mode after deleting - it does not copy.

Bcc

The cc command deletes the entire current line and enters insert mode for replacement - it modifies rather than copies.

C1c

1c is a change command with a count of 1, meaning it deletes and enters insert mode rather than yanking text.

DyyCorrect

The yy command is vi's standard 'yank line' shorthand, which copies the entire current line into the default unnamed buffer. The doubled y applies the yank motion to the whole line without requiring an explicit range. The copied content can then be pasted with p (after cursor) or P (before cursor).

E1y

1y is an incomplete command that requires a following motion; yy is the idiomatic shorthand that applies the yank to the full current line without a separate motion.

Concept tested: vi editor yank current line command

Source: https://man7.org/linux/man-pages/man1/vi.1p.html

Topics

#vi editor#yank#buffer#copy line

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice