250+ TOP MCQs on Vi Basics and Modes and Answers

Unix Multiple Choice Questions & Answers (MCQs) on “Vi Basics and Modes”.

1. Which editor is used by the UNIX system to edit files?
a) vi
b) notepad
c) word
d) notepad++

Answer: a
Clarification: It doesn’t matter what kind of work we are doing on a UNIX system, we always need an editor to edit some system files or ordinary files. For this purpose, vi editor is used in UNIX. Currently, vim (vi improved) is an improved version which is supported by LINUX systems.

2. What does the following command do?

a) open file named file001
b) edit file named file001
c) delete a file named file001
d) open file if it exists else creates a new file

Answer: d
Clarification: vi editor can be used for creating and editing files. In the above command, if file001 already exists, then the contents of the file will be displayed. Otherwise, an empty file named file001 will be created.

3. Which option is used by vi editor to open a file in read mode only?
a) -r
b) -R
c) -d
d) -f

Answer: b
Clarification: To open an existing file in read-mode only, -R is used with the filename (as an argument). For example,

$ vi  -R  file001       // open file in read mode only

4. How many types of modes are used by vi editor?
a) 2
b) 4
c) 3
d) 1

Answer: c
Clarification: Before working with vi editor, it is necessary to be familiar with the modes in which vi editor works. There are three different kinds of modes, namely command mode, input mode and ex mode each of which is used for a specific purpose.

5. What is the default mode of vi editor?
a) Command mode
b) Input mode
c) Ex mode
d) Insert mode

Answer: a
Clarification: The default mode of vi editor is command mode, where every key which is pressed is interpreted as a command to run on the text. To perform operations on text like deleting, copying, the first step you’ll have to follow is to be in the command mode so that you can run commands according to your suitability.

6. To insert text into a file, _____ mode is used.
a) Command mode
b) Input mode
c) Ex mode
d) def mode

Answer: b
Clarification: Input mode provides us with a feature of inputting text in files. Every key pressed in this mode is recorded in the file.

7. ex mode is used for what purpose?
a) file handling
b) substitution
c) file handling and substitution
d) Inputting text in files

Answer: c
Clarification: ex mode performs various file handling and substitution operations like saving the file, quitting the editor, search and replace operations etc.

8. Which one of the following key is used to switch from command mode to input mode?
a) i
b) :
c) esc
d) ;

Answer: a
Clarification: To switch from command mode to input mode press the ‘i’ key.

9. ____ key is used for switching to command mode from input mode.
a) i
b) A
c) :
d) esc

Answer: d
Clarification: Command mode allows us to enter commands for performing operations on the text entered. To switch from the input mode to command mode press the ‘esc’ key. This operation will not be displayed on the screen but changes our mode to command mode.

10. Which of the following key is used to enter in ex-mode?
a) ESC
b) i
c) :
d) ;

Answer: c
Clarification: To enter into ex-mode press the ‘:’ key. After that, we can press any ex-mode command followed by [Enter] to perform suitable operations.

Leave a Reply

Your email address will not be published. Required fields are marked *