Unix Questions and Answers – Customizing Vi Editor

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Customizing Vi Editor”.

1. For searching a character, ___ and ___ are used.
a) f, t
b) n, w
c) e, d
d) k, n
View Answer

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

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

Answer: a
Explanation: t command works in a similar manner as f except the fact that it positions the cursor a single character before the occurrence.
advertisement
advertisement

4. __ and __ commands works in a reverse manner as f and t.
a) F, T
b) tf, ft
c) z, x
d) ff, tt
View Answer

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

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

Answer: d
Explanation: vi can be customized in the way we want. For this purpose, map, set and abbr commands are used.
advertisement

7. vi environment is determined by variable settings. These variables are controlled by ____ command.
a) :set
b) :abbr
c) :map
d) autowrite
View Answer

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

Answer: b
Explanation: To provide automatic indentation to or code, we can use the following statement:

advertisement
:set  autoindent

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
View Answer

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

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

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

Answer: b
Explanation: /* 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
View Answer

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

Answer: b
Explanation: The y operator yanks text but it cannot perform any function unless it is combined with any command or itself.

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.