Craig's Handy "vi" Guide CURSOR POSITIONING Ctrl-F go forward a page Ctrl-B go backward a page Ctrl-U go up half a page Ctrl-D go down half a page j go down one line (faster than Cursor-Down) k go up one line (faster than Cursor-Up) H go to the top of the screen M go to the middle of the screen L go to the bottom of the screen G go to the bottom of the document 1G go to the top of the document nnnG go to line number 'nnn' of the document (most positioning and modification commands can be done 'nnn' times by ( using a repetition prefix; use ESC to abort entering the prefix) w go forward one word b go backward one word 0 go to the first column of the current line $ go to the last column of the current line ^ go to the first non-whitespace character on the line Ctrl-L repaint current screen (is Ctrl-R on some systems) TEXT MODIFICATION u undo the last change U undo all changes made to a line since you last moved to the line i enter text-insertion mode (ESC to finish) Ctrl-V insert character(s) of a keystroke verbatim, while in insert mode A append text to the end of a line (ESC to finish) x delete the character under the cursor cw change current word cc change the entire current line (ESC to finish) r replace current character with the next character you type R overwrite the current line from the current position (ESC to finish) J join the next line of text to the current one ~ alter the case (upper/lower) of the letter under the cursor . repeat the last modification operation ma set marker 'a' to the current location (you can name markers 'a'--'z') 'a go to marker 'a' y'a yank (copy) text from current location to marker 'a' into the kill buf. yy yank the current line into the kill buffer d'a delete text from current location to marker 'a' into the kill buffer dd delete the current line into the kill buffer p put (insert) the text in the kill buffer after the current line P put (insert) the text in the kill buffer before the current line :r fn read file 'fn' into the document after the current line (commands that start with ':' are finished by pressing Return) SEARCH & REPLACE /str forward-search for the text string 'str' (can be a regular expression) ?str reverse-search for the text string 'str' n find the next occurrence of the last-searched-for string (fwd/backwd) :s///g replace occurrences of (reg. expr.) with string . : "%" for entire file (no quotes), "." for cur. line, "7,$" for lines 7-end. The ending "g" means to replace all occurrences on a line FILE OPERATIONS ZZ exit and save the document if modified :w write text to a file (:w! for force) :w fn write text to file 'fn' (without changing document name) (:w! to force) :q quit (:q! for force) :vi go back into full-screen mode after going into ':' mode Crtl-G display current line number being edited and whether text is modified :n go onto the next filename given on the command line FILTER EXAMPLES !}fmt -79 1G!Gexpand -4 :set noautoindent wrapmargin=0 tabstop=4 shiftwidth=4