How to exit from Vim/Vi is a common question asked by most of the new users who don’t have much experience with the Vim/Vi editor. Vi is a Linux command line editor and Vim is the enhanced version of Vi.
In this tutorial we are going to explain few different methods on how to exit Vim.
- Press the Esc key to enter “Normal mode” in the vim editor.
:wqto save the new changes to the file and exit.
:qto exit. You can’t just quit like this if there are any changes.
:q!to exit without saving the changes you have made.
These three methods are the basics you can use to exit from the Vim/Vi editors. It’s very simple. You can edit the file by switching into insert mode by pressing
i key and return back to normal mode by pressing
You can see the command type in the normal mode at the bottom left corner of the terminal.
More Options to exit from Vim/Vi editor
There are more options available to play around with the Vim editor other than the above-mentioned methods. You can practice all the methods and apply as you prefer in practical usage of vim editor.
:xin normal mode to write and exit
:exitin normal mode to write and exit (same as
ZZin normal mode to save and exit (same as
- Type ZQ in normal mode just to exit (same as
:qain normal mode to quit all
In this short tutorial, we explained how to use different methods to exit from vim. This is one of the most googled questions by developers. Hope you can understand the simply explained tutorial and please comment on all your doubts and suggestions.