This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Editing Text in Vi Editor – 1”.
1. Copying is referred to as yanking in vi editor.
Explanation: Copying text or characters is known as yanking in vi editor.
2. Which key is used for deleting text?
Explanation: ‘d’ is not a command but is used as ‘dd’ to delete entire lines. For example, to a delete a line invoke the command mode and press dd and the entire line will be deleted.
3. Which command is used for deleting a single character?
Explanation: The simplest text deletion is achieved using ‘x’ command. This command deletes the character under the cursor and then the text on the right shifts towards the left to fill up space.
4. Which command is used for deleting the character on the left of the cursor?
Explanation: For deleting a single character, we can use ‘X’ command. It deletes a single character but to the left of the cursor.
5. Which of the following command is used to delete a single line?
Explanation: We can delete entire lines with ‘dd’ command. Just move the cursor anywhere on the line and press ‘dd’ and the entire line will be deleted.
6. Which of the following commands will be used to delete 6 lines from the current cursor location?
Explanation: ‘dd’ command can be used with repeat factor to delete multiple lines at a single time. 6dd will delete the current line and 5 lines below.
7. Which command is used for putting deleted lines or part of lines at a different location?
a) p and P
Explanation: Using ‘p’ and ‘P’ command we can put deleted text at a different location. For example, if we’d deleted a single character using ‘x’ then we can put that character at another location by placing the cursor at that location and pressing ‘p’ or ‘P’.
8. Both ‘p’ and ‘P’ command puts text right/left or above/below on the basis of line deleted.
Explanation: If we’d deleted a part of a line, then ‘p’ will put it to the right of the cursor and ‘P’ will put it to the left of the cursor. Similarly, if we’d deleted the entire line then ‘p’ will put it below the current cursor and ‘P’ will put it above the cursor.
9. To copy (yank) lines in vi editor, we use ______ command.
Explanation: To copy lines in vi editor, we can use ‘yy’ command. It works similarly as ‘dd’ command. For example, to yank 5 lines from current cursor we can use the command ‘5yy’.
10. To copy 10 lines from the current cursor location, we can use _____
Explanation: Since yanking is performed by the yy command hence to copy the current line and 9 lines below we can use the command ’10yy’.
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.