I'm quite new to Vim so I first checked the help.txt file to inform myself about Vim. Here I saw the following:
Close this window: Use ":q".
Get out of Vim: Use ":qa!" (careful, all changes are lost!).
The first one closes Vim. The second one also. Wouldn't all changes also go with :q? To be clear, I use the vim GUI not a command prompt.
edit: It's more about the difference, not the actual meaning. The almost same explanation in the help.txt file confused me.
:qa! Close all files, abandon changes. :w. Save.
1. :wq = "Write and quit".
Press Esc to enter Command mode, and then type :wq to write and quit the file. The other, quicker option is to use the keyboard shortcut ZZ to write and quit. To the non-vi initiated, write means save, and quit means exit vi.
W is like the industrial-strength next-word command, words are only delimited by whitespace, be it tab, space or newline. w stops at the delimiting punctuation also, in case you want to deal with that. With w , you stop on each part of the hostname and the dots. W just skips the entire hostname and goes onto the # .
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)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With