~
Change between uppercase and lowercase
cm
Change text block defined by movement command m
(e.g., cw changes next word)
cc
Change current line
C
Change to end of line
R
Type over characters
s
Delete character and continue typing
S
Delete current line and continue typing
Delete, Move
x
Delete character
X
Delete character to the left of the cursor
dm
Delete text block defined by movement command m
(e.g., dw deletes next word)
dd
Delete current line
D
Delete to end of line
p, P
Put deleted text before, after cursor
"n
p
Put text from delete buffer number n
after cursor (for last nine deletions)
Yank (copy)
ym
Yank (copy) text block defined by movement command m
(e.g., yw yanks next word)
yy, Y
Yank current line
"ayy
Yank current line into named buffer a
p, P
Put yanked text before, after cursor
"aP
Put text from buffer a before cursor
Other Commands
.
Repeat last edit command
u
Undo last edit
U
Undo changes to current line
J
Join two lines
[Ctrl]L, [Ctrl]R
Redraw screen
Invoking vi
vi
Invoke vi editor on file
file
vi
Invoke vi editor on files sequentially
file1 file2
view
Invoke vi editor on file
in readonly mode
file
vi -R
Invoke vi editor on file
in readonly mode
file
vi -r
Recover file
and recent edits after system crash
file
vi +
Open file
at last line
file
vi
+n file
Open file at line number n
vi
+/pattern file
Open file at pattern
Exit and Save Commands
ZZ
Save file and quit
:x
Save file and quit
:wq
Save ("write") file and quit
:w
Save file
:w!
Save file (overriding protection)
:30,60w
Save lines 30 through 60 as file newfile
newfile
:30,60w>>
Append lines 30 through 60 to file file
file
:w
%.new
Save current buffer named file as file.new
:q
Quit
:q!
Quit, discarding any changes
Q
Quit vi and invoke ex
:e
Edit file2
without leaving vi
file2
:e!
Discard changes to current file, then edit file2
without leaving vi
file2
:n
Edit next file
:e!
Discard all changes since last save
:e#
Edit alternate file