Vim is a great editor.
Yeah sure it has its own little weird ‘flaws’, but when you think about it, it is all these ‘flaws’ which actually makes it such a productive tool.
A lot of us use it, but sometimes we may get confused with one or things on how to manage the editor.
In this stupidly-short-simple guide, I’ll show you in less than 5 seconds on how you can exit your Vim editor so that you don’t have to waste your time fretting and googling for a righteous answer.
This is a guide that you may want to bookmark and keep with you always or at least until you’ve learnt the shortcuts off by-heart. 🙂
How to Exit Vim editor: 2 Steps
Step 1: Go ahead and Hit the Esc key and you’ll find that Vim goes into command mode.
Step 2: Once you’ve done that, then you can type any of the below:
- :q to quit (short for :quit)
- :q! to quit without saving (short for :quit!)
- :wq to write and quit (think write and quit)
- :wq! to write and quit even if file has only read permission (if file does not have write permission: force write)
- : x to write and quit (similar to :wq, but won’t write if there are no changes)
- :qa to quit all (short for :quitall)
When you press :, a : will appear at the bottom of your screen.
Or you can press Esc ZZ (Esc Shift+Z Shift+Z) to write/save if the file was ever changed, then quit.
Or if you don’t want to save changes, then you can use ZQ instead.
Vim has extensive help, so type Esc:helpReturn and you will have all your answers and even a neat tutorial.
Share this guide with any other developers you may know who might be having a tough time with their Vim editors or might be interested to learn some new shortcuts that may benefit their productivity.
They’ll appreciate it. 🙂