When I use :tabnew myfile
in vim it opens a new tab.
When I quit the tab with :q
and I move to another tab with :bn
, the tab is still there.
Can someone explain why and how to really close it?
^Wc (or :close[!] ) closes the current window. If the hidden option is set and this is the last window referencing this file, Vim closes the window and the buffer is hidden. If this window is on a tab page and is the last window for that tab page, the window and the tab page are closed.
To close a tab, use :tabc. To switch to the next tab, use :tabn, and to switch to the previous tab, use :tabp (short for tabnext and tabprevious respectively). You can also jump over tabs by using :tabn 2, which will move to the second next tab.
You can use :tabclose
.
Read more with :help tabpage
.
As for the buffer coming back with :bn
, I believe this is normal for "hidden buffers", and :bn
wraps around to the first buffer when you go past the last one.
See :help buffer-hidden
You're mixing up tabs and buffers. A tab is simply a way of displaying buffers, closing it doesn't do anything to those.
If you want to delete a buffer from the buffer list, use :bd
. From the help:
:[N]bd[elete][!] *:bd* *:bdel* *:bdelete* *E516* :bd[elete][!] [N] Unload buffer [N] (default: current buffer) and delete it from the buffer list. If the buffer was changed, this fails, unless when [!] is specified, in which case changes are lost. The file remains unaffected. Any windows for this buffer are closed. If buffer [N] is the current buffer, another buffer will be displayed instead. This is the most recent entry in the jump list that points into a loaded buffer. Actually, the buffer isn't completely deleted, it is removed from the buffer list |unlisted-buffer| and option values, variables and mappings/abbreviations for the buffer are cleared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With