Vim: Exiting Cheat Sheet

:q[uit]Quit VimThis fails when changes have been made.
:q[uit]!Quit without writing
:qaQuit all buffers / tabs
:cq[uit]Quit always, without writing
:wqWrite the current file and exit
:wqaQuit and write all buffers / tabs
:wq!Write the current file and exit always
:wq {file}Write to {file}. Exit if not editing the last
:wq! {file}Write to {file} and exit always
:[range]wq[!]Write the lines in [range] and exit always
ZZWrite current file, if modified, and exit
ZQQuit current file and exitSame as :q!.

Leave a Reply

Your email address will not be published. Required fields are marked *