vi Command Summary



next up previous contents index
Next: Editing with Emacs Up: Editing with vi Previous: Editing with vi

vi Command Summary

 

MOVEMENT - moving the cursor and scrolling the screen
CHANGES - making changes to text
COPY and PASTE


vi MOVEMENT (Figure 1.2)
Arrow keys to move cursor.
h j k l
Same as arrow keys above.
w
Move forward one WORD.
b
Move BACK one word.
e
Move to END of word.
^ u
Scroll UP a partial screen.
^ d
Scroll DOWN a partial screen.
^ f
Scroll FORWARD a full screen (page down).
^ b
Scroll BACKWARD a full screen (page up).
-
Move up one line.
[ret]
Return, move down one line.
0 (zero)
Move to BEGINNING of line.
$
Move to END of line.
G
Go to END of file.
n G
Go to line number n.


vi SEARCH
/text [RET]
SEARCH for text.
/ [RET]
CONTINUE search for previous text.
?text
Search backwards for text.

vi CHANGES
s
SUBSTITUTE for character.
S
SUBSTITUTE for line.
i text [Esc]
INSERT text before cursor.
cw text [Esc]
CHANGE word to text.
c3w text [Esc]
Change 3 words to text.
C text [Esc]
Change rest of line to text.
cc text [Esc]
Change line to text.
x
DELETE single character.
r p
REPLACE single character with p.
R text [esc]
Replace (type over) characters with text.
dw
DELETE word (4dw deletes 4 words).
dd
DELETE line (3dd deletes 3 lines).
D
DELETE from cursor to end of line.
u
UNDO last change (remember this one).
U
UNDO all changes to line (don't forget this one).
s
SUBSTITUTE character.
S
SUBSTITUTE lines.
J
JOIN lines.
a text [Esc]
ADD text after cursor.
A text [Esc]
ADD text to end of line.
I text [Esc]
INSERT text at start of line.
o text [Esc]
OPEN new line below with text.
O text [Esc]:
OPEN new line above with text.
esc, or `
END an insert, replace command.

vi SUBCOMMANDS
:w fname
WRITE (save) fname (default: to present file).
ZZ
EXIT the editor, saving all changes (same as :wq).
:q!
QUIT emphatically, do not save changes (! is your
tool to insist; useful after messing up (also :w temp).
:e!
Edit again previous file, i.e., revert to last saved version.
:n
Edit NEXT file (after vi file1 file2 ...).
:f
Show current FILE name and cursor line number.

vi COPY and PASTE
Y [RET]
YANK (copy) current line.
yy [RET]
YANK (copy) current line.
yw
YANK (copy) next word.
p
PUT last thing yanked before cursor.
P
PUT last thing yanked after cursor.



next up previous contents index
Next: Editing with Emacs Up: Editing with vi Previous: Editing with vi