Vim Scoops / Lessons / Exit Vim
How to exit Vim
Press Esc, type :q and press Enter. If Vim refuses because you've changed something, use :q! to throw the changes away or :wq to save them first.
The keys
| Keys | What they do |
|---|---|
:q | Quit. Refuses if there are unsaved changes |
:q! | Quit and throw away unsaved changes |
:wq or :x | Save, then quit |
:qa! | Quit every open file, no questions asked |
The colon opens Vim's command line at the bottom of the screen. Whatever you type there runs when you press Enter, so quitting is a short command, not a single key.
When Vim says E37: No write since last change, it isn't being difficult. It's stopping you from losing work. Adding ! tells it you mean it.
Related
Want all of Vim, in order? Vim Scoops is a free game that starts at h j k l and builds up to macros.
Play the full game