Closing hidden buffers
If you spend a lot of time in Vim, you may end up with dozens or hundreds of open, hidden buffers. A buffer is a file you may have worked in during the current Vim session but stashed away behind the scenes. Over time, having so many open buffers could drag you down. To see your current buffers, just run
If you’re like me, you might want to tidy up a bit and close all your hidden buffers. Here’s how:
:up | %bd | e#
First, this updates your current buffer (saves it). Then it closes all open buffers, then it reopens the last buffer. If you want this clean slate regularly, you can create a command from this in your
command Bd :up | %bd | e#
This allows you to run
:Bd to close (delete) all other open buffers. Here’s a quick demo of this in action:
For even more control over open buffers and mappings for moving around them, check out the BufExplorer plugin.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?