vi file
// Opens 'file' in vi, or creates a file named 'file' if it does not exist.
vi file1 file2
// Opens files sequentially.
view file
// OPens 'file'inread-only mode.
vi -R file
// Opens 'file'inread-only mode.
vi -r file
// Recovers 'file' after system crash.
vi + file
// Opens 'file' at last line.
Exit vi Editor
ZZ
// Saves changes and exits.
:x
// Saves changes and exits.
:wq
// Saves changes and exits.
:w
// Saves changes.
:q
// Quit.
:q!
// Quit without saving changes.
:wq file
// Saves as'file'and exits.
Insert, append
i
// Insert text beforecursor.
I
// Insert text at beginning ofcurrent line.
a
// Append text after cursor.
A
// Append text at the endofcurrent line.
o
// Openand insert text innew line below current line.
O
// Openand insert text ine new line above current line.
r
// Replace single characteratcursor position.
R
// Replace multiple character starting withcharacteratcursor position.
s
// Substitute a single character.
S
// Substitute entire line.
Delete
x
// Deletes a single character at cursor position.
X
// Deletes a single character before cursor positon.
dw
// Deletes from cursor position tonext word.
dd
// Deletes entire line cursor ison.
D
// Deletes remainder of line, starting at cursor position.
[Ctrl] u
// Deletes from cursor to beginning of line.
d$
// Deletes from cursor toendof line.
d^
// Deletes to first characterin line, preserving indentation.
ndd
// Deletes n number of lines (2dd deletes 2 lines).
nx
// Deletes n number of characters, starting withcharacter under cursor (2x deletes 2 characters).
Yank, Copy
yw
// Yank word.
yy
// Yank current line.
:y
// Yank current line.
y^
// Yank from cursor to first characterof line.
y0
// Yank from cursor to beginning of line.
y$
// Yank from cursor toendof line.
Y
// Yank current line.
nyy or nY
// Yank n number of lines (2yy or2Y copies 2lines).
Paste
p
// Pasteafter cursor.
P
// Paste before cursor.
Search
/word
// Search forward for'word'.
?
//Repeats previous '/' search.
n
// Repeat last search in same direction.
N
// Repeat last search in opposite direction.
*
//Search forward for word under the cursor.
#// Search backward for word under the cursor.
fx
// Search forward fornext'x'on same line.
Fx
// Search backward for previous 'x'on same line.
tx
// Search forwark forcharacter before next'x'.
Tx
// Search backward forcharacterafter previous 'x'on same line.
Move cursor
H
// Move to highest visible line on screen (top line).
M
// Move to middle of screen (center).
L
// Move to lowest visible line on screen (bottom line).
l
// Move right.
h
// Move left.
K
Move up.
j
Move down.
^
// Move to first characteron current line.
$
// Move to last column on current line.
0
// Move to first column on current line.
+
// Move to first characteronnext line.
-
// Move to first characteron previous line
w
// Move to beginning ofnext word.
b
// Move to beginning of previous word.
(
// Move to beginning of current sentence.
)
// Move to beginning ofnext sentence.
{
// Move a paragraph back.
}
// Move a paragraph forward.
G
// Move to first characteron last line.
gg
// Move to first characteron first line.
Move screen
[Ctrl] d
// Move backward half screen.[Ctrl] f
// Move backward full screen.[Ctrl] u
// Move forword half screen.[Ctrl]b// Move forward full screen.[Ctrl] e
// Move up one line.[Ctrl] y
// Move down one line.
G
// Move to last line infile.
nG
// Move to n number line.
Other
.
// Repeat last edit command.
u
// Undo last change.
U
// Undo all changes on line.