Unix Questions and Answers – Vi-Input Mode

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Vi-Input Mode”.

1. Input mode is used for ____________
a) editing text in files
b) invoking commands on files
c) saving files
d) performing substitution
View Answer

Answer: a
Explanation: To enter text in a file, we have to first switch to input mode. To enter into input mode, press ‘i’ once. Any key pressed after that will appear on the screen as text input.

2. Which command is used to insert text before the current cursor location?
a) a
b) A
c) I
d) i
View Answer

Answer: d
Explanation: If the ‘i’ command is invoked with the cursor positioned on the existing text, text on the right of the cursor will be shifted further right without getting overwritten.

3. Which command will be used to insert text at the beginning of the line?
a) i
b) I
c) a
d) A
View Answer

Answer: b
Explanation: ‘I’ command is used to insert text at the beginning of current line irrespective of the cursor position in the current line.
advertisement
advertisement

4. To append text after the current cursor location, we can use ____ command
a) A
b) a
c) i
d) I
View Answer

Answer: b
Explanation: To append text after the current cursor location, use the ‘a’ command. If there is already existing text after the cursor location then it will be simply shifted towards the right.

5. Which command appends text at the end of the current line?
a) A
b) a
c) i
d) I
View Answer

Answer: a
Explanation: To append text at end of current line use ‘A’ command. It appends the text at line extreme.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. To replace a single character, we use ____ command
a) r
b) R
c) s
d) i
View Answer

Answer: a
Explanation: To replace a single character based on cursor location, ‘r’ command is used. To replace a single character, type ‘r’ followed by the character that replaces it. It replaces a single character under the cursor.

7. vi automatically switches from command mode to input mode when we press ‘r’.
a) True
b) False
View Answer

Answer: a
Explanation: When ‘r’ is pressed, vi momentarily switches from command mode to input mode and returns to command mode automatically after the new character is entered.
advertisement

8. To replace all text on the right of the cursor position, we use ____ command.
a) r
b) R
c) s
d) I
View Answer

Answer: b
Explanation: The only difference between ‘r’ and ‘R’ is that ‘R’ can replace all text on the right of the cursor position while ‘r’ only replaces a single character.

9. Which one of the following command is used to replace a single character with many?
a) s
b) r
c) R
d) S
View Answer

Answer: a
Explanation: ‘s’ is used to replace a single character with many characters. It replaces a single character based on the current cursor position with a group of characters.
advertisement

10. To replace 5 characters with new characters, which one of the following will be used?
a) s
b) 5S
c) 5s
d) S
View Answer

Answer: c
Explanation: To replace multiple characters, we can use the repeat factor. 5s replaces five characters with new text whatever will be entered.

11. To replace the entire line irrespective of cursor position, we can use ____ command
a) s
b) 10s
c) S
d) 10s
View Answer

Answer: c
Explanation: ‘S’ replaces the entire line with a stream of characters entered irrespective of the current cursor position. The current line is deleted while using ‘S’ command.

12. After using ‘s’ or ‘S’, we are automatically left in insert mode.
a) True
b) False
View Answer

Answer: a
Explanation: After replacing text with ‘s’ or ‘S’ we are automatically left in insert mode.

13. Which command creates a space for entering a new line of text below the current cursor location?
a) o
b) O
c) a
d) S
View Answer

Answer: a
Explanation: ‘o’ command allows us to create a new line for entering the new text below the current cursor location.

14. To create a space for entering a new line of text above the current cursor location, ‘O’ command is used.
a) True
b) False
View Answer

Answer: a
Explanation: ‘O’ command allows us to insert an empty line above the current cursor location. Hence, to create a space for entering a new line of text above the current cursor location, ‘O’ command is used.

15. Which of the following command is not used for entering or replacing text?
a) ‘a’ and ‘A’
b) ‘s’ and ‘S’
c) ‘r’ and ‘R’
d) :q
View Answer

Answer: d
Explanation: All the above commands are used for either appending or replacing except :q which is used in ex-mode to quit from vi editor.

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.