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
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
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
Explanation: ‘I’ command is used to insert text at the beginning of current line irrespective of the cursor position in the current line.
4. To append text after the current cursor location, we can use ____ command
a) A
b) a
c) i
d) I
View Answer
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
Explanation: To append text at end of current line use ‘A’ command. It appends the text at line extreme.
6. To replace a single character, we use ____ command
a) r
b) R
c) s
d) i
View Answer
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
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.
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
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
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.
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
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
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
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
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
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
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.
- Practice MCA MCQs
- Check Unix Books
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Check Computer Science Books