Ibuffer for looking at your buffers in Emacs

Navigating in Emacs if you have a lot of buffers open, can be done in different ways. The most basic one is using the key combination Ctrl+x Arrow Right or Left for the next or previous buffer. If there are a lot of buffers open, this is not an option. Another option is using the buffer list C-x C-b. The buffer list contains all the open buffers, but finding the one you are looking for might take some time.
I prefer to use ibuffer which offers you many possibilities for looking at your buffers. It is part of Emacs since version 22.  In the next figure you see my buffers grouped according to their mode (org, R, LaTeX, Gams, Text and all remaining buffers). The menu gives you lots of opportunities to work with the buffer list.
One of the nice features is marking for example all org files: just put the cursor on [ Org ], hit the space bar and all files are marked (see next figure). Now you can easily save all of them or delete them. Another example: with “S” you can save all unsaved buffers.
I added the following lines to my .emacs file. The first lines set C-x C-b as the shortcut for opening the buffer list with ibuffer. The next group of commands tells ibuffer which modes to group (you can add other groups if you like).
(global-set-key (kbd “C-x C-b”) ‘ibuffer)
(autoload ‘ibuffer “ibuffer” “List buffers.” t)

(setq ibuffer-saved-filter-groups
(“Org” (or (mode . org-mode)
(filename . “OrgMode”)))
(“R” (or (mode . ess-mode)
(filename . “EssMode”)))
(“LaTeX” (or (mode . latex-mode)
(filename . “LaTeXMode”)))
(“Gams” (or (mode . gams-mode)
(filename . “GamsMode”)))
(“Text” (name . “.txt”)))))

(add-hook ‘ibuffer-mode-hook
‘(lambda ()
(ibuffer-auto-mode 1)
(ibuffer-switch-to-saved-filter-groups “home”)))
(setq ibuffer-show-empty-filter-groups nil)

3 thoughts on “Ibuffer for looking at your buffers in Emacs

Leave a Reply

Your email address will not be published. Required fields are marked *