VIM is an enhanced version of VI text editor. It is a highly configurable text editor to edit files very efficiently. Many Linux beginners face issues with exit form vi/vim editor. This tutorial will help you to exit the Vim text editor on the Linux command line.
How to Exit Vim?
As we have already seen in advanced Vim tips, there are multiple ways to quit Vim. Let me list them one by one along with the procedure.
You have several ways to exit from the Vim text editor. But you need to choose the right command to exit from Vim editor based on your decision. Remember that the exit command always runs from Vim command mode. So you need to press
ESC to go to command mode. Now type a colon
: to before writing exit command.
- ESC + :w – Save changes and continue editing.
- ESC + :q – Quite (exit) from vim editor, only if no changes made.
- ESC + :wq – Write changes and quite from Vim editor.
- ESC + :q! – Quit Vim editor without saving any changes (discard all changes made after last saved).
- ESC + :wq! – Forecefully save changes and quick from editor.
Quit Vim using Keyboard Shortcuts
You can also use keyboard shortcuts to exit from the vim editor. No need to type anything. Press
ESC to make sure you are in command mode.
- Shift + z + z – save changes and exit
- Shift + z + q – exit without saving changes