Unix Questions and Answers – Vi-Ex Mode – 1

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

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

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

Answer: b
Explanation: Pressing ‘:x’ in ex-mode will save the file on the disk and returns the shell prompt.
advertisement
advertisement

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

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

Answer: a
Explanation: Pressing ‘:w’ doesn’t quit the editor but simply saves the editing we’ve done so far in the specified file.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. We can specify the filename with ‘:w’ command.
a) True
b) False
View Answer

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

advertisement

7. Which command is used for saving and quitting the editor simultaneously?
a) :q
b) :w
c) ‘:x’
d) :f
View Answer

Answer: c
Explanation: ‘:x’ command saves our content and quits the editor simultaneously. This command is invoked in ex-mode.
advertisement

8. Which of the following command is a substitute for ‘:x’ command?
a) ‘:x’
b) :wq
c) :q
d) :w
View Answer

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

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

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

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.