Unix Questions and Answers – Editing Text in Vi Editor – 1

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

Answer: a
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

Answer: a
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

Answer: c
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.
advertisement
advertisement

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

Answer: b
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

Answer: a
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

Answer: c
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

Answer: a
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’.
advertisement

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

Answer: a
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

Answer: d
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’.
advertisement

10. To copy 10 lines from the current cursor location, we can use _____
a) 10y
b) 10yy
c) yy10
d) 10x
View Answer

Answer: b
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.