BELUG > vi > previous

Summary of Commands

The following list contains the basic commands presented in the first eight pages of this tutorial along with occasional examples of usage (shown in parenthesis). They are presented in roughly the same order in which they appear in the tutorial. (All commands that begin with a colon are followed by ENTER.)

vi typed at the command line to open one or more files in the same directory
(vi tomato.txt   opens a file named "tomato.txt" in the current directory)
(vi parsley sage rosemary   opens the three files "parsley," "sage" and "rosemary" in the current directory)
vi *typed at the command line to open every file in the current directory
:q closes (quits) a file to which no changes have been made
:q! quits without saving any changes
:w writes (i.e., saves) the current file to disk
:wq writes the buffer contents to disk (i.e., saves changes) and quits
ZZ same as :wq
i activates text insert mode, inserting text immediately under the current position of the cursor
h moves the cursor one character to the left
(2h   moves the cursor two characters to the left)
j moves the cursor one line down
(3j   moves the cursor three lines down)
k moves the cursor one line up
l moves the cursor one character to the right
G moves the cursor to the desired line; moves the cursor to the last line of text if not preceded by a modifying integer
(5G   moves the cursor to the fifth line)
a switches to insert mode and allows insertion of text immediately to the right of the cursor
x deletes the character immediately under the cursor
(xxx   deletes the character immediately under cursor and then deletes the two characters to its right)
X deletes a single character to the left of cursor
D removes the text on the current line from the character under the cursor to the end of the line
dw deletes the character immediately under the cursor and the remaining characters to the right of it in the same word
(2dw   deletes the character immediately under the cursor, the remaining characters to the right of it in same word and all of the next word)
dd deletes the entire line containing the cursor, and the cursor then moves to the next line
(2dd   deletes two consecutive lines beginning with the current line)
cw deletes the character under the cursor and to its right in the same word and allows new characters to be typed in to replace them
(2cw   deletes the character under the cursor and to its right in the same word and in the next word, and then allows replacement characters to be typed in)
cc erases the current line and allows replacement text to be typed in
(2cc   erases the current line and the next line and allows replacement text to be typed in for both lines)
cb deletes the characters to the left of the cursor in the current word and allows replacement characters to be typed in
(3cb   deletes the characters to the left of the cursor in the current word together with the two words to its left and then allows replacement text to be typed in)
R activates text input mode allowing text under and to the right of the cursor to be overwritten one character at a time
xp transposes two adjacent characters
deep transposes two adjacent words
ddp transposes two adjacent lines
~ changes case of the character under the cursor
J joins the current line with the next line
u reverses the effects of the most recent command that has changed the buffer
U undoes all changes made to the current line during the current visit to it
:s/ searches the text for the first instance of a designated string
(:s/cucumber   searches the text for the first instance of the string "cucumber")
n searches the text for the next instance of a designated string
:s/ / / replaces the first instance of a designated string
(:s/cucumber/radish/   replaces the first instance of the string "cucumber" with the string "radish")
:%s/ / / replaces every instance of a designated string
(:%s/cucumber/radish/   replaces every instance of the string "cucumber" with the string "radish")
:r inserts text into the currently open file from another file
(:r lettuce.txt   inserts text into the currently open file from the file named "lettuce.txt")
:w>> appends the text from the currently open file into another file
(:w>> cabbage   appends the text from the currently open file into the file named "cabbage")