How do I close all open tabs at once?

2019-03-07 19:44发布

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

How can I close them all at once?

标签: vim vi shortcuts
6条回答
Summer. ? 凉城
2楼-- · 2019-03-07 19:55

Shortest/simplest/fastest way would be:

:qa

To save work in all tabs and quit:

:wqa
查看更多
放我归山
3楼-- · 2019-03-07 20:01

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.

  2. :conf qa :confirm qall

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

  3. :qa! :qall!

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

  4. :quita :quitall :quita! :quitall!

    Same as :qall.

  5. :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.

  6. :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.

  7. :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
查看更多
叼着烟拽天下
4楼-- · 2019-03-07 20:04
:qall

This closes all tabs and open buffers.

查看更多
干净又极端
5楼-- · 2019-03-07 20:16

I often use :tabo to close all other tabs.

查看更多
Melony?
6楼-- · 2019-03-07 20:16

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.

查看更多
放我归山
7楼-- · 2019-03-07 20:17

Adding to what fuentesjr said:

:qa!

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

查看更多
登录 后发表回答