All help refers to VISUAL mode, unless a preceeding colon (:) is specified. Note: This text is a summary intended to provide only a basic outline. ----Invocation---- vi file ; Edit at first line of 'file' vi file1 file2 ; Edit file1. Edit file2 via :n vi [options] file ; As above, but with Command Line Options Command Line Options: +n ; Edit at line n + ; Edit at last line +/pattern ; Edit at line containing 'pattern' -R ; open file(s) in read-only mode -c ; Use line-oriented command mode -e ; ... restricted 'edit' mode. -l ; Enable 'lisp' and 'showmatch' options -wn ; Specify window size of 'n' lines -? ; Print a summary of all command line options ----Exiting---- ZZ ; Exit visual mode, saving changes :x ; Exit saving changes :wq ; Write buffer, then quit. :w ; Write buffer to original file :w file ; Write buffer to 'file' :w>> file ; Append to 'file' :n,mw file ; Write lines 'n' through 'm' to 'file' :q ; Quit out of editor :q! ; Quit discarding changes :e! ; Reedit file, discarding changes ----Setting Options---- :set all ; Prints all option settings :set option ; Enables option 'option' :set nooption ; Disables option 'option' :set option? ; Prints current value of 'option' :set ; Prints modified options ----Text Input---- i ; Insert before cursor I ; Insert before first non-blank on line a ; Append after cursor A ; Append at end of line o ; Open and insert at line below O ; Open and insert at line above ;ESCape key terminates Input mode. ----Insert Mode Commands---- Control-@ ; Repeat Last Insertion Control-W ; Erase last word entered Control-H ; Erase last character entered DELete or Backspace ; Same as Control-H Control-U ; Erase entire line Control-D ; Backtab over 'autoindent' 0Control-D ; Kill all 'autoindent' ^Control-D ; Kill 'autoindent' on current line only Control-V ; Next character literal (to insert control codes) ----Screen Adjustment---- Control-L ; Clear and redraw screen Control-R ; Redraw only if @ (deleted) lines zCR ; Redraw, current line at top of page z. ; Redraw, current line at center of page z- ; Redraw, current line at bottom of page /pattern/z- ; Redraw, line containint 'pattern' at bottom of page zn. ; Redraw, set new window size of 'n' lines Control-E ; Scroll down 1 line Control-Y ; Scroll up 1 line Control-F ; Scroll forward one screen Control-B ; Scroll backward one screen Control-D ; Scroll down half screen Control-U ; Scroll up half screen ----Cursor Motion---- H ; Move cursor to top of page M ; ... to middle of page L ; ... to last line of page + ; ... to next line at first non-white character - ; ... to previous line at first non-white down-arrow or j ; ... down one line, staying in same column up-arrow or k ; ... up one line, staying in same column left-arrow or h ; ... to the left right-arrow or l ; ... to the right 0 ; ... to beginning of line ^ ; ... to beginning of line (first non-white) $ ; ... to the end of line n| ; ... to column 'n' Control-H ; Same as left-arrow ----File Motion---- G ; Last line of file nG ; Line 'n' of file /pattern ; Next line containing 'pattern' ?pattern ; Previous line containing 'pattern' n ; Next / or ? N ; previous / or ? /pattern/+n ; 'n'th line after line containing 'pattern' ?pattern?-n ; 'n'th line before line containing 'pattern' ) ; Next sentence ( ; Preceding sentence } ; Next paragraph { ; Preceding paragraph ]] ; Next section/function [[ ; Preceding section/function `` ; Previous context '' ; Previous context at first non-white in line ----Search Patterns---- ^ ; Beginning of line $ ; End of line . ; Any character * ; Zero or more of previous character [A-Z] ; Matches any character from A to Z [abc] ; Matches a, b, or c [^abc] ; Matches any character BUT a, b or c \ ; escape character for literal: \ / $ . ^ [ ' & * | ~ \< ; Beginning of word \> ; End of word ----Marking Position---- mx ; Mark current position with locater 'x' `x ; Return to position at locater 'x' 'x ; ... at first non-white in line ----Yank and Put---- yy or Y ; Yank line to buffer yw ; Yank word to buffer nyy or nY ; Yank 'n' lines to buffer p ; Put back lines below cursor P ; Put back lines above cursor "xy ; Yank line to buffer 'x' "xp ; Put from buffer 'x' ----Substitution---- stext ; Substitutes 'text' for character until ESCape S ; Substitute for entire line until ESCape :s/X/Y/opt ; Substitute 'Y' for first occurence of 'X' ; Options: g - Change every currence in line ; c - Confirm each change ; p - Print each change (Command mode only) & ; Repeat last :substitute command :g/X/s//Y/opt ; Globally find the first 'X' on each line and ; substitute 'Y' for the string 'X' ----Deleting Text---- x ; Delete character under cursor nx ; ... 'n' characters X ; ... character before cursor dw ; ... word ndw ; ... 'n' words dd ; ... entire line dtx ; ... to 'x' in current line D ; ... to end of line d/pattern ; ... up to 'pattern' d?pattern ; ... back to 'pattern' d`x ; ... to marked location 'x' d'x ; ... current line and to line which contains marked location 'x' d) ; ... to end of sentence d( ; ... to beginning of sentence d} ; ... to end of paragraph d{ ; ... to beginning of paragraph d]] ; ... to end of section d[[ ; ... to beginning of section ----Changing Text---- cw ; Change word ncw ; ... 'n' words cc ; ... entire line ncc ; ... 'n' lines C ; ... to end of current line c/pattern ; ... up to 'pattern' c?pattern ; ... back to 'pattern' c`x ; ... to marked location 'x' c'x ; ... current line and to line which contains marked location 'x' c) ; ... to end of sentence c( ; ... to beginning of sentence c} ; ... to end of paragraph c{ ; ... to beginning of paragraph c]] ; ... to end of section c[[ ; ... to beginning of section rx ; Replace character with 'x' R ; Replace all characters until ESCape is entered ----Word and Within Line Motions---- w ; Move cursor forward by one word W ; ... including any punctuation b ; Move cursor backward by one word B ; ... including any punctuation e ; Move cursor forward to end of word E ; ... including any punctuation fx ; Search current line (only) forward for 'x' Fx ; Search current line (only) backward for 'x' ; ; Repeat last 'f' or 'F' , ; Reverse of last 'f' or 'F' ----Undo---- u ; Undo last change U ; Restore current line "np ; Retrieve from buffer 'n' (1-9 and a-z) "n1pu.u.u.u. ; Scan recent deletions ----Miscellaneous---- . ; Repeat previous operation ~ ; Reverse case of letter and advance one position J ; Join lines together << ; Shift line left one tab position >> ; Shift line right one tab position :g/pattern/p ; Locate and print all occurances of 'pattern' within the file xp ; Reverse order of two letters dwwP ; Reverse order of two words ddp ; Reverse order of two lines