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.
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)- A5% (1)
- D95% (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.
The c command is a change operator that requires a motion argument and switches to insert mode after deleting - it does not copy.
The cc command deletes the entire current line and enters insert mode for replacement - it modifies rather than copies.
1c is a change command with a count of 1, meaning it deletes and enters insert mode rather than yanking text.
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).
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
Community Discussion
No community discussion yet for this question.