Linux How To Exit Vi / Vim
If you aren’t used to using the Vi editor it can be a little bit frustrating. Even simple things like how to exit Vim can be tricky. Fortunately, this is all really easy once you know what you are doing.
To exit Vim do the following:
- Hit the [Esc] key to switch back to command mode.
- Use one of the following:
:wq | save changes and exit |
:x | save changes and exit |
:w | write changes but don’t exit |
:q | exit if there are no changes |
:q! | exit without saving changes |
ZZ | exit and save |
ZX | exit, don’t save |
Here is an animated gif showing how to exit Vim.