Reputation: 3209
I know that :qa
closes all the buffers and windows and exits vim. It's also clear that I could use :q
to quit a single window/split in a given tab. But consider the case where I have three windows in the current tab and a bunch of adjacent open tabs as well. I want to close the three windows in the current tab but not quit vim or the other adjacent tabs.
How do I do it? I went through the vim help file, but there doesn't seem to a direct option. I imagine it's possible to get such functionality using vimscript, but I want to be sure before drawing the conclusion that it's the only option.
If vim doesn't support it directly and someone has been awesome enough to write a plugin for it, I would love to know about it.
Upvotes: 19
Views: 4419
Reputation: 7985
The existing answers which suggest :tabc[lose]
are correct. However, there is one situation in which another answer may be useful.
In the case that you want to close the windows in the current tab to reduce the number of things you have open before opening a new tab and pulling some new files into it, the tabclose
option still works; succinctly, you would do :tabc|tabe
. However, the Vim purist in me can't help but point out that you could save yourself three keystrokes by typing :on|ene
instead, which is short for :only | enew
, or "close all windows except this one in the current tab; now, open a new unnamed file in this window." And if want to replace the current windows with a named file, this idiom is two more keystrokes shorter than the other, for a total of five: :on|e foo.txt
versus :tabc|tabe foo.txt
.
So while the generally correctly answer to the question is the :tabclose
command, there are cases in which :on|e
or :on|ene
are more useful.
Upvotes: 2
Reputation: 42647
Do you mean you want to close the current tab page? Then there's the :tabclose
command for that.
Upvotes: 30
Reputation: 3209
I also found out this command works. The help page at help tabpage
was quite useful.
:tabc
Like @glts pointed out in a comment, I needed to get my vim terminology in order before I could find an answer.
Upvotes: 5