Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close multiple vim buffers interactively?

Tags:

vim

After a while having a text editor open, especially after performing a fairly substantial refactor that touches a large number of files, you end up with a lot of buffers open.

In emacs I had become accustomed to using kill-some-buffers, which basically starts in interactive yes/no session, presenting each buffer's name and allowing you to press y or n to either keep or delete each buffer, until all buffers have been presented to you (or you cancel the command).

Is there a way to do the equivalent in vim? I can use a wildcard, but the filenames are all ruby files with different names (basically every file in my project). Easiest thing is for me to just close all buffers and start over, but that's not really the solution I'm looking for, just for my own future reference.

If I could open a split window with a list of all the buffers and "mark" each buffer I want to close in some way, then "commit" that decision, that would work too. Basically just something that doesn't require me to apply thought-provoking logic to the process of closing a bucket-load of buffers.

like image 460
d11wtq Avatar asked Dec 29 '25 20:12

d11wtq


1 Answers

I have found the plugin buffet which allows similar things:

  • Use :Bufferlist to open the list of buffers.
  • Move up and down with the usual keys (j, k).
  • Delete the buffer under cursor with d

I think that is similar enough to mark the buffer for deletion.

like image 162
mliebelt Avatar answered Jan 01 '26 17:01

mliebelt