1. What is the command used to display line numbers in vi editor?

esc
:
set number
Repeating in Descriptive form

Please come to command mode by pressing escape.
Put :
The typoe set number and enter

You can view line nos

3. How to return to shell without leaving vi editor?

In the vi Press 'Esc' and ':' then Type 'shell'
And you can go to shell and do different commands.
To return to vi editor type 'exit' in shell prompt.

4. How to create a .exrc file in vi editor?

This article presents a sample .exrc file that can be used
by users of the vi editor. The .exrc file, located in your
home directory, is the startup (or configuration) file for
the vi editor.

The intent of this brief article is to show some of the
ways you can modify the configuration of the vi editor



Please note that the .exrc file contains commands that Vi
reads when you first run it. The default directory that Vi
looks in for the .exrc file is your home directory.
However, if you run Vi from another directory containing
a .exrc file, Vi will use the .exrc in that directory and
bypass the home directory .exrc. You must precede control
characters (like ^[ or ^M) with CONTROL-V. For example to
enter ^M, type CONTROL-V CONTROL-M.


Some important points for .exrc files:

Do not allow any blank lines in the file or processing will
stop on that line.
Comments are introduced by starting a line with a double
quote: "
All directives, whether options, abbreviations, or key
macros must all be typed on a single line. The listing
below has had the lines broken up for the sake of
readability.
Control characters like [tab],[linefeed],[escape] can be
inserted by first typing ^V (hold down Ctrl, and press V),
followed by the character. For instance, for [tab], hold
Ctrl and press V, release Ctrl, hit [tab]. You'll see ^I.
This is evident in the listing below.
For VIM the corresponsing file is .vimrc (_vimrc in case of
windows).

6. What is the difference between ZZ and :wq commands?

both do the same task..! in the sense :wq,:x and ZZ
are used to save the changes of edited to storage and quit..
but to jot down the difference a foolish one.. :wq and :x
requires <enter> key to be pressed to fire this commands
where as ZZ works as a shortcut (hot) key.. it some what
like for prior commands we are requesting Vi to do the work
and later command we are telling/commanding

7. What is the command used to replace many characters?

this question should bhave been for many same words that
appear many times, for this press escape to go to command
line, then type
:%s/old_word/new_word/g
g for global

8. How to enter from command mode to insertion mode?

There are several commands that put the VI editor into
insert mode. The most commonly used commands to get into
insert mode are a and i.

9. Which command is used to replace many characters?

change command can be used to change a word/line.

cw change word forward
cb change word backward
c$ change from cursor to end of line
cL change from current line to and of screen
cG change from current line to and of file

or if you want to replace all occurence of some specific
character

:%s/oldText/newText/g

10. What does the /text command do?

/text: it will search for the string(pattern).You will get
the first occurance after pressing enter.If you wanna see
the next occurance then press "n"

Download Interview PDF

12. What are the different commands used to quit from the vi editor?

q! IS THE COMMAND TO QUIT FROM vi EDITOR WITHOUT SAVING
wq IS THE COMMAND TO QUIT FROM vi EDITOR WITH SAVING
q IS THE IS THE COMMAND TO QUIT FROM vi EDITOR IF YOU DONT
EDIT ANYTHING AFTER OPENING THAT FILE

13. What are the different delete commands used in vi editor?

dd -- for delete line
x - single character deletion
dw - delete word

14. What are the two different modes in vi editor?

Command Mode
Insert Mode
LastLine mode

15. What is the difference between lettered buffer and temporary buffer?

Temporary Buffer

Deleted or copied text goes into a temporary unnamed
buffer. The contents of the temporary buffer may be
retrieved by using the p or P commands.

Lettered Buffers

There are 26 lettered buffers (a-z). Contents of a lettered
buffer are saved until you copy or delete more characters
into it, or until you quit your current vi session.

eg.
From Command Mode

"ayy Copy (yank) a line into buffer letter "a"
"ap Put contents of lettered buffer a below the
current line

17. How to append a file to current file?

to append file1 to file2. first open file1 in vi editor
using vi file1 command. then to append file1 to file 2 just
use the following command.

:w>>file2 so file 1 will be appended to file 2

18. What does the c$ command do from command mode?

c$ will begin from the character under the curser till the
end of line. so when you use this command it will show you $
sign at the end of the line and you can change till that point.