Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

For compiling a C program without leaving the editor, which command will be used?(a) cc %(b) :! Cc(c) :!cc %(d) :!cThe question was posed to me during an online interview.Enquiry is from Customizing Vi Editor topic in chapter Advanced Vi of Unix

Answer»

The correct answer is (C) :!cc %

Best explanation: vi provides US with a feature of compiling a C program WITHOUT leaving the editor by using the :!cc % command.

2.

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 filesThe question was asked by my school teacher while I was bunking the class.This intriguing question originated from Customizing Vi Editor in division Advanced Vi of Unix

Answer» CORRECT ANSWER is (b) y and yy are same

Best explanation: The y operator YANKS text but it cannot perform any function UNLESS it is combined with any command or itself.
3.

/* and f* are same.(a) True(b) FalseI have been asked this question in an interview for internship.This is a very interesting question from Customizing Vi Editor in portion Advanced Vi of Unix

Answer»

The correct CHOICE is (b) False

The best explanation: /* will search the entire FILE for an asterisk, while f* looks for it in the CURRENT line only.

4.

To change the default tab stop spaces in vi, ___ can be used with :set.(a) nomagic(b) tabstop=n(c) tab(d) tabchangeThe question was asked in an interview for job.My question comes from Customizing Vi Editor topic in portion Advanced Vi of Unix

Answer»

The correct choice is (b) tabstop=n

Easiest EXPLANATION: To change the default tab SETTING (8 spaces) to 4 spaces, :SET tabstop=4 can be USED.

5.

Which command is used for mapping keys of a keyboard?(a) set(b) map(c) abbr(d) autowriteThe question was posed to me in an interview.I want to ask this question from Customizing Vi Editor topic in portion Advanced Vi of Unix

Answer»

Right option is (B) map

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.

6.

Which of the following is used with :set to customize vi to ignore case in pattern searches?(a) nomatch(b) ignorecase(c) nocase(d) nomagicThis question was posed to me during an interview.I need to ask this question from Customizing Vi Editor topic in division Advanced Vi of Unix

Answer»

Correct answer is (B) ignorecase

To explain I would say: To CUSTOMIZE the VI to ignore case in PATTERN searches we can use the following statement:

7.

For automatic indentation, ____ is used with : set command.(a) autowrite(b) autoindent(c) automode(d) showmodeThis question was posed to me in an internship interview.The doubt is from Customizing Vi Editor in portion Advanced Vi of Unix

Answer»

The correct OPTION is (b) autoindent

To explain I would say: To provide automatic indentation to or CODE, we can use the following STATEMENT:

8.

vi environment is determined by variable settings. These variables are controlled by ____ command.(a) :set(b) :abbr(c) :map(d) autowriteThis question was posed to me by my school principal while I was bunking the class.My question is taken from Customizing Vi Editor topic in portion Advanced Vi of Unix

Answer»

Correct answer is (a) :SET

Best explanation: vi environment is determined by variable SETTINGS. These variables are controlled by :set COMMAND.

9.

For customizing vi, which of the following command is used?(a) set(b) map(c) abbr(d) set, map, abbrThe question was posed to me at a job interview.I need to ask this question from Customizing Vi Editor in division Advanced Vi of Unix

Answer»

The correct option is (d) set, map, abbr

The explanation is: vi can be CUSTOMIZED in the way we want. For this PURPOSE, map, set and abbr COMMANDS are USED.

10.

For repeating the character search , and ; are used.(a) True(b) FalseI got this question in examination.The above asked question is from Customizing Vi Editor topic in division Advanced Vi of Unix

Answer»

The correct answer is (a) True

Easiest 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.

11.

__ and __ commands works in a reverse manner as f and t.(a) F, T(b) tf, ft(c) z, x(d) ff, ttThis question was addressed to me in class test.The origin of the question is Customizing Vi Editor in chapter Advanced Vi of Unix

Answer»

The CORRECT choice is (a) F, T

Best explanation: F and T perform the RESPECTIVE FUNCTIONS as f and t but in reverse direction.

12.

For moving the cursor forward to the first occurrence of a character, __ is used.(a) d(b) t(c) f(d) nI got this question by my school teacher while I was bunking the class.The query is from Customizing Vi Editor in section Advanced Vi of Unix

Answer»

Right option is (c) F

The BEST I can explain: For moving the cursor forward to the first occurrence of a CHARACTER, f command is used FOLLOWED by the character. For example,

13.

t command positions the cursor a single character before the occurrence.(a) True(b) FalseThis question was posed to me during a job interview.Question is from Customizing Vi Editor topic in portion Advanced Vi of Unix

Answer»

Correct option is (a) True

Best EXPLANATION: t command works in a similar manner as f except the fact that it POSITIONS the cursor a SINGLE character before the occurrence.

14.

For searching a character, ___ and ___ are used.(a) f, t(b) n, w(c) e, d(d) k, nI got this question in a national level competition.My doubt stems from Customizing Vi Editor topic in section Advanced Vi of Unix

Answer»

Correct choice is (a) f, t

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.

15.

Which of the following is an invalid command?(a) :r file01(b) :e file01(c) :e#(d) :w # file01The question was asked in an interview for internship.I'd like to ask this question from Handling Multiple Files and Buffers in chapter Advanced Vi of Unix

Answer»

Correct choice is (d) :w # file01

Explanation: : r file01 will read the contents of file01 below the CURRENT line. :efile01 will stop editing the current FILE and will EDIT file01. Similarly, :e# RETURNS to editing most recently edited file.

16.

To append contents of buffer to file01, we can use __________(a) : w >> file01(b) :r > file01(c) :w > file01(d) :r >> file01This question was addressed to me by my school principal while I was bunking the class.My doubt is from Handling Multiple Files and Buffers topic in chapter Advanced Vi of Unix

Answer»

Correct ANSWER is (a) : w >> file01

For EXPLANATION I would say: The command :w >> file01 will append the CONTENTS of BUFFER to the file specified.

17.

vi used ___ to enter control characters.(a) ctrl-w(b) ctrl-v(c) ctrl-d(d) escThis question was posed to me in quiz.I'd like to ask this question from Handling Multiple Files and Buffers topic in division Advanced Vi of Unix

Answer»

The CORRECT answer is (b) ctrl-v

To explain: In vi, some CHARACTERS are directly ENTERABLE, but a control CHARACTER has to be PRECEDED by another control character for it to be interpreted properly. Vi used ctrl-v to precede any control character.

18.

For restoring the contents of numbered buffers efficiently, ___ command is used.(a) .(b) $(c) :nb(d) :qThe question was posed to me in homework.My query is from Handling Multiple Files and Buffers in chapter Advanced Vi of Unix

Answer» RIGHT choice is (a) .

The explanation: vi offers the DOT COMMAND to RESTORE the CONTENTS of any buffer efficiently. Every time this command is pressed, it steps through the buffer set to restore the contents of the next buffer.
19.

The technique of restoring line deletions from numbered buffers is applicable only to entire lines.(a) True(b) FalseThe question was asked in an international level competition.The above asked question is from Handling Multiple Files and Buffers in chapter Advanced Vi of Unix

Answer»

The correct choice is (a) True

Easy explanation: The technique of restoring LINE DELETIONS from numbered buffers is APPLICABLE only to entire lines. For example, we can’t restore five words deleted with 5dw unless it was the LAST editing action performed.

20.

To restore a number of recent deletions, numbered buffers are used.(a) True(b) FalseI got this question in an interview for internship.This interesting question is from Handling Multiple Files and Buffers topic in portion Advanced Vi of Unix

Answer»

The correct OPTION is (a) True

To elaborate: We often need to RESTORE a number of RECENT deletions. Vi editor MAKES it possible to restore up to recent nine COMPLETE line deletions using its numbered buffers. For example,

21.

vi editor has ____ named buffers.(a) 2(b) 4(c) 26(d) 5This question was addressed to me by my college director while I was bunking the class.I need to ask this question from Handling Multiple Files and Buffers topic in section Advanced Vi of Unix

Answer»

Correct choice is (c) 26

The best I can explain: vi editor STORES the deleted text in an unnamed BUFFER. But this suffers some limitations. i.e. we can use only one buffer at one TIME. So vi uses 26 special named BUFFERS which are named after the letters of the alphabet. For example,

22.

To remove all other windows except the current one, which of the following command is used?(a) :on(b) :new(c) :n(d) :rThe question was asked in class test.This is a very interesting question from Handling Multiple Files and Buffers in section Advanced Vi of Unix

Answer»

The correct answer is (a) :on

Best explanation: To make the current window the only window on the screen and close all other WINDOWS USE :on command. We can also kill the current window USING :Q.

23.

To create a new window, ____ can be used.(a) :sp(b) :new(c) :n(d) :rThe question was asked in an online quiz.Enquiry is from Handling Multiple Files and Buffers in portion Advanced Vi of Unix

Answer»

Right choice is (c) :n

The explanation is: We can also create an empty window which will not be ASSOCIATED with any file. For this purpose, :new command is used. Now we can MOVE between these WINDOWS using ctrl-w.

24.

To split the screen into multiple windows, we can use ____ command.(a) :sp(b) :new(c) :n(d) :rThis question was posed to me in examination.Question is taken from Handling Multiple Files and Buffers topic in section Advanced Vi of Unix

Answer»

Correct option is (a) :sp

For explanation I would say: We can ALSO split our screen into MULTIPLE windows using :sp command. The WINDOW can be EMPTY or it can contain a FILE, even a copy of the same file.

25.

We can move back to the previous file using ____ command.(a) new(b) :n(c) :rew(d) :prevThis question was addressed to me in class test.The question is from Handling Multiple Files and Buffers topic in chapter Advanced Vi of Unix

Answer»

The correct answer is (c) :rew

For explanation: When VI editor is used with MULTIPLE FILENAMES, it loads the first file. We can switch to NEXT file using :n command. In this manner, we can reach to the last file. At any stage, we can MOVE back to the first file using :rew command.

26.

:r!date inserts the output of date command in our file.(a) True(b) FalseThe question was asked during an online exam.This interesting question is from Handling Multiple Files and Buffers topic in portion Advanced Vi of Unix

Answer»

Correct option is (a) True

To explain: We can also INSERT the output of any command in our FILE USING :R command.

27.

When multiple filenames are used with vi, we can switch to next file using ___ command.(a) new(b) :n(c) :rew(d) :prevThis question was addressed to me during an interview.This intriguing question originated from Handling Multiple Files and Buffers topic in section Advanced Vi of Unix

Answer»

Right option is (c) :rew

To EXPLAIN I would say: When VI editor is used with multiple filenames, it loads the first file. We can switch to next file USING :n COMMAND.

28.

For returning back to the original file after switching we can use:(a) :e!(b) ctrl-^(c) :e#(d) ctrl-^ and :e#This question was addressed to me during an interview.Asked question is from Handling Multiple Files and Buffers in division Advanced Vi of Unix

Answer»

The correct CHOICE is (d) ctrl-^ and :e#

Best explanation: We can switch between multiple FILES without quitting the vi editor. For this PURPOSE, :e command is used. For returning back to the original file, we can use ONE of the following COMMANDS:

29.

Which of the following command is used for switching files?(a) :e(b) e!(c) !e(d) !rI got this question in an international level competition.This interesting question is from Handling Multiple Files and Buffers in section Advanced Vi of Unix

Answer»

Right answer is (a) :e

For EXPLANATION: We can SWITCH between multiple FILES without quitting the vi editor. For example, while working with one FILE, we can switch to another by USING the following command,

30.

Which of the following is not a valid operator-command combination?(a) 5dd(b) yy5(c) cc(d) yGThe question was posed to me in examination.This is a very interesting question from Operator-Command Combinations topic in chapter Advanced Vi of Unix

Answer» RIGHT ANSWER is (b) yy5

Best EXPLANATION: The command yy5 is not a VALID ONE as we cannot prefix the command yy with an integer value.
31.

To sort all lines from current cursor to end of line, ____ can be used.(a) sort .,$(b) sort !G(c) sort !,G(d) !GsortI had been asked this question in an interview for internship.My question is based upon Operator-Command Combinations in division Advanced Vi of Unix

Answer» RIGHT CHOICE is (d) !Gsort

The explanation: The sort command is combined with ! and G OPERATOR for sorting from current CURSOR to the END of the line.
32.

The command c0 will change the text from current cursor to the end of line.(a) True(b) FalseThis question was posed to me at a job interview.I want to ask this question from Operator-Command Combinations in chapter Advanced Vi of Unix

Answer»

The correct choice is (B) False

For explanation: The command c0 will change the text from CURRENT CURSOR to the beginning of LINE.

33.

To yank from current cursor up to first occurrence of string strin reverse direction, we can use:(a) y?str(b) y!str(c) yy str(d) yy ! strThe question was posed to me in an online interview.My doubt is from Operator-Command Combinations topic in section Advanced Vi of Unix

Answer»

Correct option is (a) y?str

For explanation I would SAY: The COMMAND y?str is another example of operator-command combination. The operator ? is used with y operator for yanking a string in REVERSE direction.

34.

The command df. will _____(a) deletes entire line(b) deletes entire paragraph(c) deletes from current cursor up to first occurrence of(d) deletes zero linesThis question was posed to me by my school principal while I was bunking the class.This intriguing question comes from Operator-Command Combinations topic in portion Advanced Vi of Unix

Answer»

The correct OPTION is (C) deletes from CURRENT CURSOR up to first occurrence of

To explain: The COMMAND df. is another example of operator-command combination. It deletes from cursor to first occurrence of a dot.

35.

To delete from current cursor upto the first occurrence of }, which of the following will be used?(a) dd$}(b) d /(c) d / }(d) }The question was asked during an online interview.This key question is from Operator-Command Combinations in portion Advanced Vi of Unix

Answer» CORRECT choice is (c) d / }

To EXPLAIN: We can PERFORM MANY functions using operator-command combinations. For example, d / } will deletes from the current cursor upto first occurrence of } .
36.

To change entire lines, ____ is used.(a) cc(b) CC(c) dd(d) c$I got this question during an interview.My enquiry is from Operator-Command Combinations topic in section Advanced Vi of Unix

Answer»

Right answer is (a) cc

For explanation: For changing text, C operator is used. This operator is also combined with a command to perform the REPLACEMENT. To CHANGE entire LINES, use the cc command.

37.

Which operator is used in vi to filter text?(a) %%(b) &&(c) $(d) !I have been asked this question during an online interview.Question is taken from Operator-Command Combinations in section Advanced Vi of Unix

Answer»

Right ANSWER is (d) !

The best explanation: vi provides a marvellous feature of allowing UNIX filter to ACT on the text that’s displayed on the terminal. For FILTERING text screen,

1. MOVE to the beginning of the text to be acted upon and press !

2. move to the other end of the text using navigation command like G

3. Enter the command to act on the text.

38.

c operator is used for changing the text.(a) True(b) FalseI have been asked this question in final exam.This is a very interesting question from Operator-Command Combinations in chapter Advanced Vi of Unix

Answer»

Correct answer is (a) True

Easy explanation: For CHANGING text, c operator is used. This operator is also combined with a COMMAND to PERFORM the replacement. If dw deletes a word, cw changes it. This operator WORKS in input mode. For example, to change the text from the PRESENT cursor location up to the end of line, use

c$ or C

39.

For pasting text, ____ is used.(a) p or P(b) d or D(c) C(d) x or XI had been asked this question in an online interview.My question is based upon Operator-Command Combinations in section Advanced Vi of Unix

Answer»

The CORRECT choice is (a) p or P

To explain: After yanking TEXT with YY, we can paste it using either p or P. p paste the text below the current LINE while P paste the text above the current line.

40.

For yanking text, ___ is used.(a) d(b) y(c) c(d) GThe question was posed to me during an online exam.This is a very interesting question from Operator-Command Combinations topic in chapter Advanced Vi of Unix

Answer»

Correct OPTION is (b) y

To EXPLAIN I would say: The y operator is used for YANKING (COPYING) text. It is used in the same way as d operator is used i.e. it is also combined with itself or with another command. For example,

41.

An operator can’t perform any function without being combined with a command or itself.(a) True(b) FalseThis question was addressed to me in an international level competition.The doubt is from Operator-Command Combinations in chapter Advanced Vi of Unix

Answer»

Correct CHOICE is (a) True

Best explanation: An operator alone cannot perform any function unless it is COMBINED with a command or itself. For EXAMPLE, by USING dd or yy we can DELETE or copy a line respectively.

42.

dw will ________(a) deletes one line(b) deletes one word(c) deletes one character(d) deletes one sentenceI got this question in quiz.This intriguing question originated from Operator-Command Combinations topic in chapter Advanced Vi of Unix

Answer»

Correct choice is (b) DELETES one word

To explain I WOULD say: dd command is a combination of the d operator with itself. vi can perform COMPLEX deletion when this operator is COMBINED with a command of the command mode. For example,

43.

For deleting the line form current cursor to the end of the line, we can use:(a) $(b) d$(c) dd(d) $dThis question was posed to me in a national level competition.This question is from Operator-Command Combinations topic in portion Advanced Vi of Unix

Answer»

Right option is (a) $

Best EXPLANATION: DD COMMAND is a COMBINATION of the d operator with itself. vi can PERFORM complex deletion when this operator is combined with a command of the command mode. For example,