Unix Multiple Choice Questions on “Customizing Vi Editor”.
1. For searching a character, ___ and ___ are used.
a) f, t
b) n, w
c) e, d
d) k, n
Answer: a
Clarification: For searching a character, we can take the cursor near or to a specific character in the current line. This is done with f and t commands.
2. For moving the cursor forward to the first occurrence of a character, __ is used.
a) d
b) t
c) f
d) n
Answer: c
Clarification: For moving the cursor forward to the first occurrence of a character, f command is used followed by the character. For example,
fch // moves the cursor forward to the first occurrence of ch
3. t command positions the cursor a single character before the occurrence.
a) True
b) False
Answer: a
Clarification: t command works in a similar manner as f except the fact that it positions the cursor a single character before the occurrence.
4. __ and __ commands works in a reverse manner as f and t.
a) F, T
b) tf, ft
c) z, x
d) ff, tt
Answer: a
Clarification: F and T perform the respective functions as f and t but in reverse direction.
5. For repeating the character search , and ; are used.
a) True
b) False
Answer: a
Clarification: We can repeat the character search using the ; and , respectively. ; repeats the search in the same direction along which the previous search was made with f or t. Similarly (,) repeats the search in the opposite direction.
6. For customizing vi, which of the following command is used?
a) set
b) map
c) abbr
d) set, map, abbr
Answer: d
Clarification: vi can be customized in the way we want. For this purpose, map, set and abbr commands are used.
7. vi environment is determined by variable settings. These variables are controlled by ____ command.
a) :set
b) :abbr
c) :map
d) autowrite
Answer: a
Clarification: vi environment is determined by variable settings. These variables are controlled by :set command.
8. For automatic indentation, ____ is used with : set command.
a) autowrite
b) autoindent
c) automode
d) showmode
Answer: b
Clarification: To provide automatic indentation to or code, we can use the following statement:
9. Which of the following is used with :set to customize vi to ignore case in pattern searches?
a) nomatch
b) ignorecase
c) nocase
d) nomagic
Answer: b
Clarification: To customize the vi to ignore case in pattern searches we can use the following statement:
:set ignorecase // case-insensitive search
10. To change the default tab stop spaces in vi, ___ can be used with :set.
a) nomagic
b) tabstop=n
c) tab
d) tabchange
Answer: b
Clarification: To change the default tab setting (8 spaces) to 4 spaces, :set tabstop=4 can be used.
11. Which command is used for mapping keys of a keyboard?
a) set
b) map
c) abbr
d) autowrite
Answer: b
Clarification: The map command lets us assign the undefined keys or reassign the defined ones so that when such a key is pressed, it expands to a command sequence.
12. /* and f* are same.
a) True
b) False
Answer: b
Clarification: /* will search the entire file for an asterisk, while f* looks for it in the current line only.
13. For compiling a C program without leaving the editor, which command will be used?
a) cc %
b) :! Cc
c) :!cc %
d) :!c
Answer: c
Clarification: vi provides us with a feature of compiling a C program without leaving the editor by using the :!cc % command.
14. Which of the following statement is not true?
a) f and t commands are used for searching a character
b) y and yy are same
c) vi has 26 named buffers
d) :e# is used for toggling between files
Answer: b
Clarification: The y operator yanks text but it cannot perform any function unless it is combined with any command or itself.
