This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Vi-Ex Mode – 1”.
1. To save the editing performed on a file, we have to switch to ______ mode
a) command
b) input
c) ex
d) insert
View Answer
Explanation: ex-mode allows us a feature in which we can save the editing that we have performed on a file. ex-mode also provides us features like quitting vi editor, substitution etc.
2. Pressing ‘:’ in command mode invokes which mode of vi editor?
a) ex-mode
b) insert mode
c) command mode
d) input mode
View Answer
Explanation: To invoke ex-mode we’ve to press the ‘:’ key in command mode. After pressing : , we are in ex-mode. Now simply type any command of ex-mode to perform a suitable function.
3. To save a file and return to shell prompt, which one of the following command will be used in ex-mode?
a) :w
b) ‘:x’
c) :a
d) :f
View Answer
Explanation: Pressing ‘:x’ in ex-mode will save the file on the disk and returns the shell prompt.
4. To save a file and remain in vi editor, which one of the following command will be used?
a) :w
b) ‘:x’
c) :q
d) :a
View Answer
Explanation: For saving a file and to remain in editor we can use ‘:w’ command in ex-mode. It is generally considered a good practice to save the contents of buffer regularly while working with files using ‘:w’.
5. After pressing ‘:w’, we can normally resume our editing work.
a) True
b) False
View Answer
Explanation: Pressing ‘:w’ doesn’t quit the editor but simply saves the editing we’ve done so far in the specified file.
6. We can specify the filename with ‘:w’ command.
a) True
b) False
View Answer
Explanation: To save our editing to a different file, we can specify the name of the file in which we want to save the work. To do this, simply provide the filename as an argument with ‘:w’ command. For example, to save the contents to file named ‘file002’, use the following command:
:w file002 [Enter]
7. Which command is used for saving and quitting the editor simultaneously?
a) :q
b) :w
c) ‘:x’
d) :f
View Answer
Explanation: ‘:x’ command saves our content and quits the editor simultaneously. This command is invoked in ex-mode.
8. Which of the following command is a substitute for ‘:x’ command?
a) ‘:x’
b) :wq
c) :q
d) :w
View Answer
Explanation: We can also use the ‘:wq’ command to save and quit editor but it requires an additional keystroke and it is not recommended for use.
9. Which one of the following is the best way of saving and quitting the editor?
a) ZZ
b) :wq
c) :w
d) ‘:x’
View Answer
Explanation: The best and preferred way to save and quit the editor is to use ZZ, a command mode command which is way better then ‘:x’ or :wq.
10. Which command is used to abort the editing and quit the editing mode?
a) :w
b) :wq
c) :q
d) ‘:x’
View Answer
Explanation: It is possible to abort the editing process and quit the editing mode without saving the buffer. The quit (:q) command performs this job.
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]
- Check MCA Books
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Check Unix Books
- Check Computer Science Books