vi stands for VISUAL EDITOR. This was developed by Bill joy of BSD.
vi has 3 modes:
n
Append
or Insert mode (data entry)
n
Command
or Escape Mode (editing)
n
Last
Line or Ex Mode (file operations)
$ vi new
By default, when we
invoke vi, we are in mode 2.
a append
i insert
l move the cursor right
h move the cursor left
k move
the cursor up
j move
the cursor down
x delete
one character
dw delete
one word
dd deletes
entire line
d$ deletes
from current position to the end of line
d0 deletes
from current position to the beg. of line
u undo
J join
G go
to specific line no.
r replace
one character
R replace
till esc. is pressed
o open
mode after the line
O open
mode before the line
yy yanking
pp pasting
Last Line Mode
Commands: When we press : from command or escape mode, it is printed
at the last line.
These commands are to be given at that colon.
:wq write and quit
:x write
and quit
:q! quit
without saving
:s ///g substitute globally
: w write
:w! overwrite
:n next file
:e file edit the file
:! execute a UNIX command
No comments:
Post a Comment