"vi" Brief Summary Here is a brief summary of the most useful "vi" commands. Most commands may be preceeded by a count, this indicates either the number of characters to act upon (such as in the "s") command, or the number of times to repeat the command. Note that "vi" has two modes, "command" and "insert". We will indicate if a command puts you into "insert" mode. "Insert" mode may be exited by typing . Command Resulting Mode Use of Command (editing commands) a insert Allows you to append text after the cursor. A insert Allows you to append text at the end of the current line. i insert Allows you to insert text before the cursor. I insert Allows you to insert text at the beginning of the current line. s insert Substitutes the number of characters specified by the count for what is entered during insert mode. S insert Substitute the entire line for what is typed during insert mode. r command Replace the character at the cursor with the next character typed Y command Yank the number of lines specified by count. P command Put back the yanked lines before the current line. p command Put back the yanked lines after the current line. x command eXpunge the character after the cursor. X command eXpunge the character before the cursor. dd command Delete the current line. dw command Delete the next word. D command Delete from the cursor to the end of the line. u command Undo the last change made. . command Repeat the last change made. (Positioning Within The File) h command move one character to the left. j command move down (staying in the same column). k command move up (staying in the same column). l command move one character to the right. G command Go To the line number specified by the count. If no count is given, go to the end of the file. $ command Go to the end of the line. ^ command Go to the first non-white space on the line. 0 command Go to the beginning of the line. f command (follow this command with any character). Find the character, looking left to right within the line. F command The same as "f", except look right to left. ; command Repeat the last "f" or "F" command. , command Repeat the last "f" or "F" command, in the other direction. % command Go to the matching ( or ). ^F,^B command Forward Screen (Backward Screen) ^U,^D command Up Window (Down Window) (Searching) / This leaves you on the command line at the bottom. Enter the string to search (forward) for, terminate with ? The same as /, except in the other direction in the file. n Search for the next occurance, in the same direction. N Search for the next occurance, in the opposite direction. (Miscellanous) J Join the next line to this line. :r Read the given file into the current file, placing it after the current line. :w Write the current file out. :q Quit. :wq Write and quit. :q! Quit, discarding changes. :e! ReEdit the current file, discarding changes. :1,$s/old/new/g Global change of "old" for "new". For full information on this command, see the "ex" and the "edit" manuals. ^L Redraw the current screen.