What is the difference between :q and :qa! in Vim?

I don't see any of the answers specifically addressing the meaning of 'a' so thought I'd contribute:

:q is quit, as you know, but warns you didn't save

:qa is quit, all buffers, without saving but you'll get that same warning

:qa! is quit all buffers, without saving, and without a warning


When you have some changes and use :q, it fails and throws an error stating No write since last change. In order to quit from the Vim without saving changes, you should write :q!, it will quit the Vim and ! will work as a negation, which will negate the write operation.

When you fire :qa!, it quits the vim and doesn't throw an error mentioned above as you have added !. And there is no argument like a if you see man vi. (Just to note, arguments are case sensitive and -a and -A are treated differently)

In order to save the file and then quit the vim, you should use :wq, as it will first save the file and then quit the Vim.


The key difference is the exclamation mark here. :q will warn you about unsaved changes and will not let you exit. :q! will not warn you.

See also :help quit (type that in vim)

Tags:

Vim