If you end up in vim
without warning, you probably want to know: how do I get out of here?!
Exit
The basic shortcut is simply:
:q
What does it mean?
When you type :
(the colon character) you are telling vim
to go into “command mode”. This is a special mode where you can tell vim
to do things, in this case: quit!
The q
means “quit”.
Save Changes
When you have changes, you either need to save them:
:wq
The w
means “write”, aka “write file to disk”.
Ignore Changes
When you have changes, but you don’t want to save them:
:!q
The !
means “force” or “override the safety”.