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)

:wqall!

Close all buffers without saving (shutting down vim)

:qall!

Close all buffers visually but leaving them open

:only

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

F4

Actually close all (saved) buffers except this one with

F3

Here’s how:

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

Requirements

Install the BufOnly plugin

https://github.com/vim-scripts/BufOnly.vim

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

Issues

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.