vi Quick Reference

Beginning Your Edit Session
Edit filevi [ file ]
Recover edit sessionvi -r [ file ]
Controlling Your Screen Display
Eliminate @ lines<CTRL/R>
Repaint current screen<CTRL/L>
Moving the Cursor
Beginning of current lineO or ^
Beginning of first screen lineH
Beginning of last screen lineL
Beginning of middle screen lineM
Down one linej, <RETURN>, +
End of current line$
Left one characterh, <CTRL/H>
Left to beginning of wordb or B
Right one character1, <SPACE>
Right to end of worde or E
Right to beginning of wordw or W
Up one linek or -
Beginning of next sentence)
Beginning of previous sentence(
Paging Through Text
Back one screen<CTRL/B>
Down half screen<CTRL/D>
Forward one screen<CTRL/F>
Forward to end of fileG
Move cursor to specified lineline no. G
Up half screen<CTRL/U>
Searching Through Text
Backward for pattern?pattern
Forward for pattern/pattern
Repeat Pattern searchn
Reverse direction of searchN
Creating Text
Append text after cursora
Append text after end of lineA
Insert text before cursori
Insert text at beginning of lineI
Open new line after current lineu
Open new line before current lineO
Take next character literally and display<CTRL/V>
Modifying Text
Change current wordcw or cW
Change current line (cursor to end)C
Delete character (cursor forward)x
Delete character (before cursor)X
Delete worddw or dW
Delete linedd
Delete text to end of lineD
Duplicate text(use yank and put)
Join current line with next lineJ
Move text(use delete and put)
Put buffer text after/below cursorp
Put buffer text before/above cursorP
Repeat last modification command.
Replace current characterr
Replace text to end of lineR
Substitute text for characters
Undo your previous commandu
Transpose charactersxp
Yank (copy) word to bufferyw
Yank (copy) current line to bufferY
Making Corrections During Text Insertions
Overwrite last character<DELETE>
Overwrite last word<CTRL/W>
Ending Your Edit Session
Quit (no changes made):q
Quit and save changesZZ or :wq
Quit and discard changes:q!
Using Alternate ex Commands
Copy specified lines:co or t
Display number of each text line:set nu
Move lines after after specified line:m
Read file after specified line:r file
Review current editor:set
Review editor options:set all
Set new editor option:set option
Write changes to original file:w
Write changes to specified file:w file
Write (overwrites) to existing file:w! file
Load a second file:e file
Switch between files:e#