Note: vim is a vi clone. When you launch vi, you are launching vim. 1. Enter vi (from Command Line): $ vi filename(s) $ view filename(s) # read only $ vi + filename # open at last line $ vi +n filename # open at line n $ vi +/pat filename # open at 1st line with pat $ vi -r filename # recover crashed edit 2. Leave vi (get $ prompt): ZZ (saves) :wq or :x (saves) :q (no save) :q! (no save) 3. Enter Input mode (from command mode): o open line below cursor, ready to insert O open line above cursor, ready to insert i insert before cursor I insert before 1st non-blank character on line a append after cursor A append at end of line 4. Enter Command mode (from input mode): The normal and initial state ESC key (also cancels a partial command) 5. enter Last line mode (ex editor) : [single command] (from command mode) Q [to ex editor] 6. leave Last line mode (ex editor) Return (Questions? Robert Katz: arkay@arkaye.org) or ESC (to command mode) or vi [to vi editor] 7. Editing commands: (can use number n as prefix) deleting: dd delete 1 line at cursor x delete 1 character Undoing u undo last change Repeating . repeat last command Joining J join current, next line Replacing rchar replace 1 character Rtext ESC overwrite text starting at cursor Change cw change word Change case ~ change to opposite case Transpose xp interchange two adjacent letters ddp interchange two adjacent lines Copy nyy yank n line(s) into buffer at cursor, move cursor to destination, then p put line after cursor Move ndd delete n line(s) into buffer at cursor, move to destination, then p put line after cursor 8. Cursor Movement: Return ( ), Enter, + move to beginning of next line - move to start of previous line Space bar, l move to right 1 character Backspace, h move to left 1 character j move down one line, same column, if possible k move up one line, same column, if possible 0 move to beginning of current line $ move to end of current line [n]G Go to line n or last line [no n] /pattern move forward to pattern ?pattern move backward to pattern <^F> or <^B> scroll Forward/Back <^L> or <^R> redraw screen <^G> display status data <^V>character insert character literally 9. ex commands go to line n :n go to last line :$ search :g/searchstring/[p] substitute :[addressrange]s/searchstring/newstring/[gc] import :[oneaddress]r oldfilename or :[oneaddress]r !cmd export :[addressrange]w[!] [newfilename] or :[addressrange]w >> file options :set all :set option[=value] :set nooption