Vim/Neovim: How to Write a File and Quit Even Quicker
Blatantly ripping off Ruben Schade’s post category of things you already know, unless you don’t, I share with you a way to quickly close Vim. I’ve been a Vim user for what … ten years now and just found out about this neat key binding a couple of days before.
Every Vim user is intimately familiar with the ex commands
:wqa and their exclamation mark variants. What I didn’t know is that while in
normal mode, you can simply use
ZZ to quit without writing and quit
with writing if changes were made respectively. See what
:h ZZ has to say
ZZ Write current file, if modified, and close the current window (same as ":x"). If there are several windows for the current file, only the current window is closed. ZQ Quit without checking for changes (same as ":q!").
By the way, I wasn’t aware of
:x either. I used to remap those commands to
Alt-Q – but no more.