The easiest way to exit the vim editor is by using the
:q! command. The steps are outlined in detail below:
- Press the
ESCkey to exit out of insert/append mode into command mode
- Then, press the colon key
- You will now be able to enter your command. Type q followed by an exclamation mark:
- Then, press enter
And that's all. Your document will close without saving any of the changes that you have made.
Related: How to select all in Vim
And, that's how we do it, folks! Check out our vim cheatsheet for an extensive list of vim commands to have at your disposal.