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.
a) True
b) False
View Answer
Explanation: Copying text or characters is known as yanking in vi editor.
2. Which key is used for deleting text?
a) d
b) y
c) k
d) f
View Answer
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?
a) d
b) dd
c) x
d) w
View Answer
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?
a) x
b) X
c) dd
d) d
View Answer
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?
a) dd
b) x
c) X
d) d
View Answer
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?
a) 6d
b) 6X
c) 6dd
d) 6x
View Answer
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
b) x
c) dd
d) y
View Answer
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.
a) True
b) False
View Answer
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.
a) dd
b) x
c) p
d) yy
View Answer
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 _____
a) 10y
b) 10yy
c) yy10
d) 10x
View Answer
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.
- Practice Computer Science MCQs
- Practice MCA MCQs
- Apply for Computer Science Internship
- Check Computer Science Books
- Check Unix Books