After doing a complete re-setup of my Vim environment using various standard extensions there is one behavior that annoys me quite much:
When I open a file in a split window and close that window again (":wq") Vim seems to keep the file buffer open in the background. When I now try to open the file in a different shell tab in a new Vim instance, the swap file still exists, what keeps me from editing the file.
I suppose there is a setting which makes Vim keep buffers open but hidden when I close the split, but I could not find out which one it is. What I actually desire is, that Vim really closes the buffers when I close the splits, so that I can open the corresponding files again in a parallel Vim session.
What I expect is, that the buffer is closed as soon as the last window showing it is closed via ":q".
The above command will open all buffers in a new window as follows: You can also open buffers in vertical window orientation using the following command on vim: : vertical ball. To open a particular buffer in a new window, for this purpose, issue the following command on Vim: : sbuffer.
You can also open buffers in vertical window orientation using the following command on vim: To open a particular buffer in a new window, for this purpose, issue the following command on Vim: You can also use the shortcut for this purpose. Type buffer number, then you will press ctrl w^.
Assuming the default backslash leader key, you can also press \bd to close (delete) the buffer in the current window (same as :Bclose ). Like the :bdelete command, :Bclose will fail if the buffer has been modified.
If you open a file for editing, then it automatically creates a buffer, and each file will remain accessible until you close the Vim. Press ‘Ctrl + Alt + t’ to open the terminal. Now, you will access the Vim command-line editor using the following command:
Check the value of the hidden
option using :set hidden?
. By default, vim has this set to nohidden
, which should produce the behaviour you're asking for; buffers are unloaded when they become abandoned (meaning no windows are displaying them). It's possible that this setting got set to hidden
, which causes the behaviour you're experiencing; buffers become hidden when abandoned.
Do :help 'hidden'
for more information.
I think you're confusing buffers with windows. A good explanation of the difference can be found here.
I'd also suggest this read. It has a script example that closes buffers without closing the window, which should be the effect you described.
Cheers, I hope that helps.
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