Using The VI Editor
Using The VI Editor
vi clears the screen, puts a column of "~" symbols down the left-hand side, and leaves the cursor at the
top. The "~" symbols are there to indicate end-of-file. You are now in one of vi's two modes -Command mode. Command mode is used for cursor movement, editing, retrieving and saving files,
etc. If you want to type in text, you need to be in Insert mode.
To move from Command mode to Insert mode, press "i" (no quotes).
To move from Insert mode to Command mode, press "ESC" (the Escape key).
NOTE: If your terminal doesn't have an ESC key, or the ESC key doesn't work, use Ctrl-[ instead.
Pressing "i" is but one of several ways to get into insert mode, but it is the most common. The
command list (below) will introduce others. Once in insert mode, you can type in your text. Press
ENTER at the end of each line. Use Backspace to delete to the left of the cursor. If you need to move
the cursor to another line, or make a change, or pretty much anything else, you need to press ESC to
get back to Command mode first.
Command Mode Command List
Here is a list of the most common vi commands. Most anything you'd ever want to do can be done
with one of these. Remember, these are only available from Command mode. ('Current line' means the
line the cursor is on. ^H = Ctrl-h; case is not significant on control characters.)
Cursor Movement:
h = left, j = down, k = up, l = right (the arrow keys often have the same effect)
0 = move to front of line
$ = move to end of line
w = move forward one word
b = move backward one word
e = move forward to end of word
^F = move forward a screenfull
^B = move backward a screenfull
^D = move forward half a screenfull
^U = move backward half a screenfull
G = move to end of file
#G = move to line numbered #. (Ex: Use 0G to move to top of file.)
Searching:
https://www.cs.arizona.edu/~mccann/usingvi.html
1/2
2/25/2016
https://www.cs.arizona.edu/~mccann/usingvi.html
2/2