How to close a tab in vim?
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.