(this is taken from the very end of the Beginner's Guide to VI handout) ----------------------------------------------------------------------- VI -- QUICK AND DIRTY --------------------- Starting vi Whatever you type in INSERT MODE vi is entered into your file. COMMAND Starting vi with a file MODE is used for moving around, vi filename deleting, saving, quitting, etc. Insert (go to INSERT MODE) In INSERT MODE i -- insert before cursor DEL -- erase previous character a -- insert after cursor (append) CTRL-U -- erase to start of o -- open a new line below insert or line O -- open a new line above ESC -- go to COMMAND MODE All commands below are performed in COMMAND MODE Deleting Saving and quitting x -- erase character at cursor :w -- save (write) file dd -- delete line :q! -- quit without saving ndd -- delete n lines (eg, 10dd) :wq -- save and quit dw -- delete word ZZ -- same as :wq Moving around Undo h or left-arrow -- move left u -- undo last command l or right-arrow -- move right j or down-arrow -- move down Miscellaneous k or up-arrow -- move up J -- join this line with next $ -- go to end of line % -- find matching ( ) { } ^ -- go to beginning of line CTRL-L -- redraw messy screen w -- move forward one word /xyz -- find word "xyz" CTRL-F -- forward one page CTRL-B -- back one page Useful options nG -- go to line n (eg, 10G) :set ai -- autoindent G -- go to last line :set nu -- show line numbers