List of VI Commands

Vi Command Reference

To open Vi, simply type "vi" at the command prompt in a Unix terminal.

Unix Command Reference

Moving the Cursor
h One space to the left
j One space to up
k One space down
l One space to the right
<Return> Beginning of new line
- Beginning of previous line
^ Beginning of current line
$ End of current line
<Space> Forward one space
nG Beginning of line n
b Beginning of current word
w Beginning of next word
e End of current word
Control - e Scroll forward
Control - b Scroll backward
/pattern First occurence of pattern
n Next occurence of pattern
N Previous occurence of pattern
/ Repeats last pattern search
Text Insertion and Deletion
a Appends text to the right of the cursor
A Appends text at the end of the line
i Inserts text to the left of the cursor
I Inserts text at the beginning of the line
o Opens a new line below the current line for text to be inserted
O Opens a new line above the current line for text to be inserted
x Deletes character at cursor position
X Deletes character left of cursor position
dd Deletes current line
dw Deletes current word
d) Deletes rest of sentence
D or d$ Deletes from cursor to end of line
P Puts back text from the previous delete
rx Replaces selected character with x
u Undoes last change
U Restores current line
:R myfile Appends file "myfile" to current file at current cursor position
DEL Overwrites last character during text insertion
ESC Stops text insertion, returns to command mode
Screen Commands
Control - I Reprints current screen
Control - L Exposes one more line at top of screen
Control - E Exposes one more line at bottom of screen
Control - F Pages forward one screen
Control - B Pages back one screen
Control - D Pages down half a screen
Control - U Pages up half a screen
Change Commands
cw Changes characters of current word until escape key is pressed
c$ Changes text up to the end of the line
C or cc Changes remaining text on the current line until escape key is pressed
~ Changes case of the current character
xp Transposes the current and following characters
J Joins current line with the next line
s Deletes current character and enters insertion mode
rx Replaces current character with x
R Replaces the following characters until escape key is pressed
yy Puts current line in a buffer without deleting the line
p Places the line stored in buffer after the current position of the cursor

 

Other helpful Vi notes:

To create or edit a vi file:

  • Type "vi myfile" where myfile is the name of the file to be created or edited.

To close a vi file:

  • ZZ -- Exits vi and saves changes made to the file.
  • :wq -- Writes changes to current file and quits edit session.
  • :q! -- Quits edit session and does not save changes.

For complete documentation on Vi, type "man vi" at the unix prompt.

Other Sharpened.net Resources:

Online Shopping | Developer Resources | Sharp Sites | Unix Commands