To exit Vim:
- If you are in edit mode, first press the
- Then enter
:wq + <Enter>to save and exit.
It's rare that you would ever want to, but to exit without saving, you can run
:q! + <Enter>
UPDATE (7-31-2020): When I wrote this I was a beginner at Vim, and couldn't understand why anyone would exit the editor without saving. Now that I've been using it for a while, I use
:q! all the time.