A system administrator is editing a configuration file using vim and is currently in Normal mode. The cursor is on the first of five consecutive lines that need to be duplicated and placed immediately below the original five lines. Which of the following command sequences is the most efficient way to accomplish this task?
The correct command sequence is 5yy followed by p. In vim's Normal mode, yy is the command to "yank" or copy the current line. By prefixing it with a number, such as 5, the command is applied to that number of lines. Therefore, 5yy yanks the current line and the next four lines. The p command then "puts" or pastes the yanked content on the line below the cursor, effectively duplicating the five lines.
5dd followed by p would delete the five lines and then paste them, which moves the lines instead of duplicating them.
yy five times, then p would only yank the first line five times, overwriting the yank buffer each time, resulting in only a single line being pasted.
c5w followed by p is incorrect as c5w is the command to "change five words", which deletes five words and enters Insert mode. This does not accomplish the goal of copying lines.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does 'yank' mean in vim?
Open an interactive chat with Bash
What happens if you use `5dd` instead of `5yy` in vim?
Open an interactive chat with Bash
What does the `p` command do in vim?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access