LFCS: Linux Foundation Certified System Administrator Exam - vi Editor Command for Copying Current Line into Buffer

Copy current line in vi editor | LFCS: Linux Foundation Certified System Administrator

Question

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

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

D

The correct answer is D. yy.

In vi editor, yy command is used to copy the current line. It copies the current line to the vi buffer (clipboard), which can be used to paste the contents later.

Here is a detailed explanation of the commands mentioned in the question:

A. c - The c command in vi is used to delete the current line and switch to insert mode. It does not copy the line to the buffer.

B. cc - The cc command in vi is used to delete the current line and switch to insert mode. It does not copy the line to the buffer.

C. 1c - The 1c command in vi is used to delete the current line and switch to insert mode. The '1' indicates that it will delete only the current line, and not any other lines. It does not copy the line to the buffer.

D. yy - The yy command in vi is used to copy the current line to the buffer. The line remains in the file and can be pasted using the p command.

E. 1y - The 1y command in vi is used to copy the current line to the buffer. The '1' indicates that it will copy only the current line, and not any other lines. The line remains in the file and can be pasted using the p command.

Therefore, the correct command to copy the current line into the vi buffer is yy.