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
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?
b) insert mode
c) command mode
d) input mode
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?
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?
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.
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.
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?
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?
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?
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?
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.