- Cheat Sheet and Example is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools







PC Software

vi / vim Cheat Sheet

Web Site

List of vi/vim Commands


Operation Action supplement
vi FILE Open the FILE for editing. If it does not exist, a new file is created.
view FILE
vi -R FILE
view is a read only version of vi.
vi +n FILE Open the FILE with the cursor positioned at the given line. vi +5 httpd.conf
vi +/STRING/ FILE Open the FILE with the cursor positioned at the first line containing the string.
vi -r FILE Opens a recovery copy of the FILE.

Saving and Quitting

Operation Action supplement
:w to write to the file.
:q Quits, but only if no changes have been made.
:q! Quits without saving, regardless of any changes.
Saves and quits.

Insert Text

Operation Action supplement
i Insert at cursor
a Insert after cursor


Operation Action supplement
x Delete character
dd Delete line 2dd ← Delete 2 lines
dw Delete word
d$ Delete to end of line


Operation Action supplement
yy Copy a line
yw Copy a word
y$ Copy from cursor to end of line


Operation Action supplement
Shift + v
Ctrl + v

Undo & Redo

Operation Action supplement
u Undo
Ctrl + r Redo

Moving Around

Operation Action supplement
k Go up 5k
j Go down
h Go left
l Go right
Moves to the start of the current line.
Go to end of line
^ Go to beginning of non-whitespace part of line
gg Go to beginning of file
G Go to end of file


Operation Action supplement
Ctrl + b Move backwards one page.
Ctrl + f Move forwards one page.
Ctrl + u Move backwards by half a page.
Ctrl + d Move forwards by half a page.
w Moves to the start of the next word
e Moves to the end of the current word
% Moves the cursor to the matching bracket, any of (), [] or {}.
H Moves to the line at the top of the screen.
L Moves to the line at the bottom of the screen.
Operation Action supplement
/WORD Search STRINGS (forward) \ = Escape
?WORD Search STRINGS (backward) \ = Escape
n Find next
N Find previous
Turn off highlighting (after a search)


Operation Action supplement
s : substitude
c : check
substitution delete linefeed code
:%s/^M//g ← ^M = Ctrl-v Ctrl-m

set command

Operation Action supplement
:set paste Paste Mode
:set noautoindent
:set autoindent
:set noai
:set ai
Disable/Enable autoindent


Operation Action supplement
Ctrl + v
move go to end line
Shit + i
# or //
Multiple Comment


software/vi/index.html.txt · Last modified: 2020/06/03 by admin

Page Tools