Vi Editor Commands
Vi Editor Commands
Vi Editor Commands
1 of 5
http://www.cs.rit.edu/~cslab/vi.html#A1.3
vi Editor Commands
Quick links...
General Startup
Counts
Cursor Movement
Screen Movement
Inserting
Deleting
Copying Code
Put Command
Find Commands
Miscellaneous Commands
Line Editor Mode
ex Commands
Substitutions
Reading Files
Write File
Moving
Shell Escape
General Startup
To use vi: vi filename
To exit vi and save changes: ZZ
or :wq
To exit vi without saving changes: :q!
To enter vi command mode: [esc]
Counts
A number preceding any vi command tells vi to repeat
that command that many times.
Cursor Movement
h
move down
move up
[return]
$
2/13/2015 5:16 PM
vi Editor Commands
2 of 5
http://www.cs.rit.edu/~cslab/vi.html#A1.3
Screen Movement
G
xG
move to line x
z+
z-
^F
^B
^D
^U
^R
redraw screen
( does not work with VT100 type terminals )
^L
redraw screen
( does not work with Televideo terminals )
Inserting
r
2/13/2015 5:16 PM
vi Editor Commands
3 of 5
http://www.cs.rit.edu/~cslab/vi.html#A1.3
Deleting
x
dd
dw
db
Copying Code
yy
Put Command
brings back previous deletion or yank of lines,
words, or characters
P
Find Commands
?
repeat last f, F, t, T
Miscellaneous Commands
2/13/2015 5:16 PM
vi Editor Commands
4 of 5
http://www.cs.rit.edu/~cslab/vi.html#A1.3
xp
^G
mx
'x
ex Commands
For a complete list consult the
UNIX Programmer's Manual
READING FILES
copies (reads) filename after cursor in file
currently editing
:r filename
WRITE FILE
:w
:#
move to line #
:$
MOVING
2/13/2015 5:16 PM
vi Editor Commands
5 of 5
http://www.cs.rit.edu/~cslab/vi.html#A1.3
SHELL ESCAPE
executes 'cmd' as a shell command.
:!'cmd'
2/13/2015 5:16 PM