Computer Labratories : The "vi" Editor - A Survival Kit!

Input Mode:
i Insert text at cursor I Insert text at beginning of line
a Insert text after cursor A Append text at line end
o Open line below cursor O Open line above cursor
Cursor Movement:
Arrow Keys Directional Movement <ctrl>d Scroll down 1/2 screen
0 Go to beginning of line <ctrl>u Scroll up 1/2 screen
$ Go to end of line <ctrl>f Scroll forward 1 screen
G Go to last line <ctrl>b Scroll backward 1 screen
n G Go to line n () Scroll by sentence f/b
hjkl Move left, down, up, right w b Scroll by word f/b
Deleting Text:
x Delete text at cursor cw Change word
dw Delete word r Replace one character
dd Delete entire line :5,10d Delete lines 5-10
Save & Quit Files:
:w Save changes to buffer :wq Save changes and quit vi
:w file Save file to new file :d! Quit without saving
:10,15w file Save lines to new file
Copy & Paste:
yy Copy line :1,2t 3 Copy lines 1-2/paste after 3
n yy Copy n lines :4,5m 6 Move lines 4-5/paste after 6
p Paste below current line P Paste above current line
Additional Commands:
u Undo previous command U Undo all changes to line
/ string Search forward for string ? string Search backward for string
n Find next string occurrence J Join previous line
:%s/oldstring/newstring/cg % (entire file) s (search and replace) /old text with new/ c (confirm) g (global - all)
Editing Options:
:set all Displays all options :set noopt Toggles option (opt) off
:set nu Displays line numbers :set ic Ignores case during search
:set showmode Displays insert mode

Last modified: May 9, 1996