Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Vim command to quit all open windows?

Tags:

vim

:q only closes the current window. If you are using tabs or split windows, you need to do :q for all of them. Also, plugins like NERDTree and MiniBufExpl have their own windows, which need to be closed individually.

Is there a command to quit all these open windows and quit Vim in a single stroke? However, if there is some buffer or window with unsaved changes, I should be asked to save it or not. Any command to achieve this?

I hope this is not a strange request, because this is how most non-Vim editors with tab or splits work.

like image 899
Ashwin Nanjappa Avatar asked Feb 02 '13 04:02

Ashwin Nanjappa


People also ask

How do I close an open file in Vim?

TL;DR – How to Exit Vim If you didn't make any changes, type :q and press Enter / return. If you made some changes and would like to keep them, type :wq and press Enter / return. If you made some changes and would rather discard them, type :q! and press Enter / return.

How do I stop a Vim command?

Use CTRL-Break on MS-DOS |dos-CTRL-Break|. In Normal mode, any pending command is aborted.


2 Answers

You can quit all loaded and open buffers, splits and tabs with:

:qa 

If you want to quit without saving:

:qa! 

You could assign a mapping to do this with a single stroke, this assigns the comma to quit everything without prompting to save:

nnoremap , :qa!<CR> 

:wqall writes before closing, that might be useful.

Type :he :qa in vim for more info

like image 93
Bjorn Avatar answered Oct 17 '22 05:10

Bjorn


you can user the

:qall :qa 

quit all the tabs opened

then you can use the command

:tabo 

quit all other's tabs

if your's vim is not tabs you can use

:on 

quit all windows

like image 33
chinacheng Avatar answered Oct 17 '22 04:10

chinacheng