Vi editor cheat sheet
A quick cheat sheet for the vi editor
less than a minute
Here is a quick cheat sheet for the vi text editor:
-
There are two modes: Command and Insert.
-
The word
INSERT
appears in the bottom left corner of the screen when that mode is active. -
If you’re not sure what mode you’re in, press
Esc
to go into Command mode. -
To move the cursor in command mode:
H
(left)J
(right)K
(up)L
(right)
-
Press
I
to activate Insert mode. -
When finished, go to Command mode and then type:
:wd
to save:q!
to discard changes
Background
Like the Spanish Inquisition, the vi editor shows up unexpectedly. I’ve seen it appear when:
- Having to resolve merge conflicts in git
- Working with console windows in cloud environments
Because I don’t normally use the editor, I tend to forget how to save changes and close it.
Vital statistics
- Last update: 12 May 20224: Refactored for the new site.
- First post: 21 September 2017