Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

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.

like image 838
MCK Avatar asked Aug 04 '17 13:08

MCK


People also ask

What is QA in Vim?

:qa! Close all files, abandon changes. :w. Save.

What does WQ mean in Vim?

1. :wq = "Write and quit".

What does WQ do in vi?

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.

What is the difference between W and W in Vim?

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 # .


2 Answers

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)

like image 99
Otto Avatar answered Oct 19 '22 23:10

Otto


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

like image 25
Robert Houghton Avatar answered Oct 19 '22 23:10

Robert Houghton