Actually close all (saved) buffers in vim A google search at present returns questions about closing all buffers easily in vim but not straightforward tutorials - which always makes me feel that the issue is not being properly solved. Well it took me a while to wade through the initial search results and actually find something that closes all saved files.

(Next post will deal with a destructive close all including unsaved files.)

Hopefully here’s an easy start for you to what should be a really basic use-case in my opinion.

Close all buffers saving everything (shutting down vim)


Close all buffers without saving (shutting down vim)


Close all buffers visually but leaving them open


Probably none of these are what you wanted.

What about actually closing them? Why isn’t this easy? Not sure. But here’s what I’m doing for now:

Actually close all (saved) buffers with


Actually close all (saved) buffers except this one with


Here’s how:

map <F3> :BufOnly<CR> "Close all other buffers but this one
map <F4> :BufOnly<CR>:bd <cr> "Close all buffers


Install the BufOnly plugin

You are using Pathogen and Git submodules aren’t you?


There seems to be a problem with this approach not updating the tabs at the top of GVim on Ubuntu so I’ll look at that too for the next post.