Tuesday, June 8, 2010

Basic commands for vi editor

I   Insert text before the cursor
A   Insert text after the cursor
:   Switch to execute mode
$   Go to last place on the line
^   Go to first place on the line
W   Next word
B   Previous word
Y   Copy. (Note: Y3W = copy 3 words; Y3J = copy 4 lines.)
P   Paste
D   Cut
X   Delete character under the cursor
®   Move cursor one space right.
¬   Move cursor one space left.
-   Move cursor up one line.
_   Move cursor down one line.
$   Move cursor to end of line.
^   Move cursor to beginning of line.
:1   Move to first line of file
:$   Move to last line of file
/   Search for a character string.
?   Reverse search for a character string.
x   Delete the character at the cursor position.
dd   Delete the current line.
p   Paste data that was cut with x or dd commands.
u   Undo.
ctrl-F   Move forward one screen.
ctrl-B   Move backward one screen.
Shift-G    Last line of the file
20 Shift-G   Go to line 20
:/wordname   to search any word in file.
:set number   to give numbering in file.
:set autoindent   to give auto numbering in file.


Note: esc or Escape command will Switch from Input mode to Command mode.
For edit,save or quit the file we have to press esc before using below commands

:w   to save file.
:q!   to quit without saving.
:wq   to save and quit.

No comments:

Post a Comment