Save and Exit Vim
Learn how to save your changes in Vim. Also learn how to discard the changes and quit Vim.


Before you see anything else, you should know how to exit Vim, either with saving your changes or discarding them.
To save or exit Vim, you must enter the command mode first by pressing Esc key.
And then you can use the following options:
- :w β Save the changes but donβt exit
- :wq β Save and quit
- :q β Just Quit (if you have unsaved changes, youβll see this warning: E37: No write since last change (add ! to override))
- :q! β Force quit (it will discard any unsaved changes)
That's it. Now that you know how to quit the Vim editor, you can see some editing tips.
Updated on Aug 22, 2025
About the author

Creator of Linux Handbook and It's FOSS. An ardent Linux user who has new-found love for self-hosting, homelabs and local AI.