I join others in recommending Ibuffer, which is similar to the classic buffer list (Buffer Menu mode) but has a lot more features. (That's if you're not using something even fancier like Ido or Helm.) M-x ibuffer
opens the buffer list in the current window, like M-x buffer-menu
. M-x ibuffer-other-window
opens the buffer list in another window (like the default C-x C-b
) and (unlike C-x C-b
) selects it.
Ibuffer has many commands that are similar to Dired. You can use d
to flag the current item for deletion and x
to actually delete all items flagged for deletion. You can use m
to put a mark on the current item and D
to delete the items that are marked (with a confirmation prompt). There are also features to mark buffers based on their properties, but they're slightly different from Dired's. In Ibuffer, use % f
to mark buffers by their file name (that's the full path including directories). So you can delete my-project
buffers with
% f ~/src/my-project/ RET D y
Another possible approach which works both in the classic C-x C-b
Buffer Menu and in Ibuffer is to sort the buffer list by names. You can then quickly flag consecutive items for deletion. In the classic buffer list, use S
(M-x tabulated-list-sort
) while the cursor is at the beginning of a file name (the lines are sorted based on what's to the right of the cursor). In IBuffer, use s f
to sort by file name (and s v
to go back to the default sort by recency).
M-x ibuffer
? Quote the doc: ( ‘% f’ - Mark buffers by their filename, using a regexp. )ibuffer
. I have reboundC-x C-b
toibuffer
and have been using it exclusively for some years now. In theibuffer
buffer, you can do?
for help.