Show Menu
Cheatography

Vi Editor Cheat Sheet (DRAFT) by

Vi Editor commands

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Starting vi

vi file
Edits file *.
vi -r file
Edits last version of file after crash.
vi + n file
Edits file and places cursor at line n.
vi + file
Edits file and places cursor on last line.
vi +/string file
Edits file and places cursor at first occurrence of string.
vi file1 file2...
Edits file1 then file2...
Files will be created when saving if they did not already exist

Saving

:w
Save changes
:w!
Save and ignore checks
:w file
Save changes to file
:w! file
Save changes to file and ignore checks
:n,mw file
Save lines n to m to file
:n,mw >> file
Save lines n to m to end of file

Quitting vi

:q
Quit (no modifi­cat­ions)
:q!
Quit and discard modifi­cations
:wq
Save modifi­cations and quit
ZZ
Same as :wq