How do I close all open tabs at once?

VimViShortcut

Vim Problem Overview


If I have 10 tabs opened, I have to close each one using ":q" separately.

How can I close them all at once?

Vim Solutions


Solution 1 - Vim

Shortest/simplest/fastest way would be:

:qa

To save work in all tabs and quit:

:wqa

Solution 2 - Vim

I often use :tabo (:tabonly) to close all other tabs.

Solution 3 - Vim

That can be done with the following command (in normal or escape mode): > > :tabdo :q >

"tabdo" apparently executes the command for all the open tabs.

Solution 4 - Vim

Adding to what fuentesjr said:

:qa!

Will force quit all tabs, if you don't care about saving.

Solution 5 - Vim

You can use any of these Vim Ex commands to Exit Multiple Windows And Buffers:

  1. :qa :qall

Exit Vim, unless there are some buffers which have been changed. (Use :bmod to go to the next modified buffer). When 'autowriteall' is set all changed buffers will be written, like :wqall.

  1. :conf qa :confirm qall

Exit Vim. Bring up a prompt when some buffers have been changed. See :confirm.

  1. :qa! :qall!

Exit Vim. Any changes to buffers are lost. Also see :cquit, it does the same but exits with a non-zero value.

  1. :quita :quitall :quita! :quitall!

Same as :qall.

  1. :wqa :wqall :xa :xall

Write all changed buffers and exit Vim. If there are buffers without a file name, which are readonly or which cannot be written for another reason, Vim will not quit.

  1. :conf wqa :confirm wqall :conf xa :confirm xall

Write all changed buffers and exit Vim. Bring up a prompt when some buffers are readonly or cannot be written for another reason. See :confirm.

  1. :wqa! :xa! :wqall! :xall!

Write all changed buffers, even the ones that are readonly, and exit Vim. If there are buffers without a file name or which cannot be written for another reason, Vim will not quit.

To read about these in Vim, type the following Ex command

:help window-exit

Solution 6 - Vim

:qall

This closes all tabs and open buffers.

Solution 7 - Vim

here is an Dark Side way of closing ALL VIM INSTANCES on Linux/Mac

:!killall vim -9

Do not use it. It does what you ask but probably not the best way but fun way

Solution 8 - Vim

I'm using the VIM plugin in VSCode and I was looking for a way to close all the tabs open on the current window.

The commands :qa and :wqa didn't work because they closed all the tabs from all the windows.

The command :tabonly closed all the tabs from the current window except the current tab.

Because I'm usually only using 2 windows at the same time, the closer I managed to get to my need was to focus on the other window and run the command :

:on

(:only) it closes all the windows except the current one.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSrikanthView Question on Stackoverflow
Solution 1 - VimfuentesjrView Answer on Stackoverflow
Solution 2 - VimChristian C. SalvadóView Answer on Stackoverflow
Solution 3 - VimmmcdoleView Answer on Stackoverflow
Solution 4 - VimDaniel NadasiView Answer on Stackoverflow
Solution 5 - VimChristopherView Answer on Stackoverflow
Solution 6 - VimVagmi MudumbaiView Answer on Stackoverflow
Solution 7 - Vimuser10146018View Answer on Stackoverflow
Solution 8 - VimValentin VignalView Answer on Stackoverflow