My preferred method: :x
. But you have a few choices:
Command | Details |
---|---|
:q | Quits, but only if no changes were made |
:q! | Quits without saving any changes. Always works |
:wq | Writes (saves) and quits. Always works. Importantly, this always saves, meaning the file’s ‘last modified’ time will change |
:x | Saves only if changes were made, and then quits. Always works. |
Now that you know how to quit vim I feel obligated to say: spend some getting familiar with it. Vim is very powerful, and has been a major improvement to my workflow; I’ll never work without it again.1
Helpful Links
- Vim
:x
command – Hashrocket
Notes
- I don’t do much work in actual Vim, but I always use the keybidnings. VSCode and JetBrains both have great Vim bindings. ↩︎