0

Here some asciinema videos, notice that in the videos, when I open another file (plugins.vim) in split using Ctrl+v it will create buffer tab named plugins.vim in the left, but when I close the plugins.vim (on the right) it will not close the plugins.vim buffer tab on the left.

Is vim work like these? If yes how do I automatically close split window with :q but also close the tab buffer on the left?

Some plugin setup : - FZF Config

9
  • 1
    I read your question a few times and it's unclear to me what you mean... Do you mean the two tabs "config.yml" and "phpunit.xml"? How are you opening the new file? From fzf or using :vsplit or similar? More details would be helpful to get you a great answer... Thanks! – filbranden May 28 '20 at 0:01
  • 1
    @filbranden Updated, sorry still learning English – mandaputtra May 28 '20 at 0:27
  • 2
    @filbranden yeah i think they are splits with different buffers (Biggybi’s comment about buffers with airline seems more accurate). But the question could use some clarity re: what is happening and how it differs from the goal – D. Ben Knoble May 28 '20 at 12:49
  • 1
    @mandaputtra could you update your post with your airline config so I can check with the same? By 'config' I mean the global variables you have in your vimrc for airline like let g:airline#extensions#tabline#show_splits = 1. Also, are you using tabeline with it? – Biggybi May 28 '20 at 19:37
  • 1
    I can't see any problem. When you close a split (:q), the buffer is not unloaded. So it's supposed to stay in your top bar. When you unload a buffer (:bd), the split goes away and the buffer is no more listed in the top bar. Do you have a different behaviour? (I'm still struggling to understand your problem). – Biggybi May 29 '20 at 0:24
1

It seems you are confused about the way Vim handles files and buffers.

Each file you open is loaded in a buffer. When hidden is set (which seems to be the case for you), closing the window (or split) where a buffer is displayed will not actually close the buffer. It stays in memory for you to reopen on demand.

This is why, when you quit a window with :q, you can still see the file name on the top bar (which is a buffer list, made by airline). The buffer is still here.

You can unload a buffer with :bd, this will remove it from the buffer list.

I suggest you take a look at :h buffers, :h :e, :h :q and :h :bd to get an overhaul sense of how Vim deals with windows and files.

1

You have a very large and elaborate config. However, it looks like you've copied it from somewhere and never bothered to check what it actually does. Unfortunately, it's a common problem for people who want "to make (Neo)Vim look pretty", but feel too lazy to read a ton of the docs.

This is the line number 3 from your "settings.vim":

set hidden                              " Required to keep multiple buffers open multiple buffers

In fact, the comment doesn't explain anything. What 'hidden' really does, it keeps all open buffers in memory even if they are not shown in any window (i.e. hidden) until Vim exit or an explicit buffer unload operation (such as ZQ, :quit!, :bunload, :bdelete, :bwipeout and so on). Typing simply :quit differs from :quit! here!

So this is right and expected behaviour. What you're going to do with this is your choice. You can set nohidden, or use :q! instead of :q, or reconfigure airline not to show the buffer list, or even do nothing and leave it as is. Just make sure you fully understand what is "a buffer" and what is "a window" in Vim slang first.

1
  • Yes it is. I just want to make eslint, and prettier setup but turn into another things I don't really like, it was more large ~ it is more slim now. I deleted a bunch of configs. Thanks a lot. – mandaputtra May 29 '20 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.