In short, use ibuffer, now; the relevant .emacs magic:
(global-set-key (kbd "C-x C-b") 'ibuffer) (autoload 'ibuffer "ibuffer" "List buffers." t)
This is so much better than the regular buffer list it's not even funny. The first thing you'll notice is font-lock colorization (welcome to the 21st century!); but the killer feature is the wealth of buffer management keyboard shortcuts. On your first trip to ibuffer, you'll want to spend a little time reading through C-h b to learn the keyboard bindings; a small sample of just the marking functions:
% f ibuffer-mark-by-file-name-regexp % m ibuffer-mark-by-mode-regexp % n ibuffer-mark-by-name-regexp * * ibuffer-unmark-all * / ibuffer-mark-dired-buffers * M ibuffer-mark-by-mode * e ibuffer-mark-dissociated-buffers * h ibuffer-mark-help-buffers * m ibuffer-mark-modified-buffers * r ibuffer-mark-read-only-buffers * s ibuffer-mark-special-buffers * u ibuffer-mark-unsaved-buffers * z ibuffer-mark-compressed-file-buffers
Once you start chaining these together, you'll wonder how you ever got along without them. For example, I commonly do * s * r t D y: mark all "special buffers" (*shell*, *scratch*, etc.); mark all read-only buffers; toggle marks (marking ordinary read-write buffers); delete marked buffers; confirm. This is handy since I often work on projects via multiple emacs instances, switching between an X11 emacs instance and a tty instance running under screen. When I switch, I want to close all the files I have open for editing (even if there are no unsaved changes), but leave *shell* and dired buffers alone.
Buffer management has historically been a real bottleneck in emacs productivity. Unlike most IDEs, emacs makes it trivial to have dozens or hundreds of buffers open simultaneously. This works great, except that working with all these buffers can become troublesome. For example, to switch to a buffer, you typically C-x b and type-complete the name; but when you have a half-dozen dired buffers all named client, it gets hard to remember whether the one you wanted was client<2> or client<5>. And, of course, the C-[left click] buffer list gets ridiculous with many buffers — you might as well be using Eclipse or something. ibuffer doesn't completely solve all these problems, but it certainly mitigates them.
I particularly value ibuffer’s ability to group buffers. For example, you can make it group your buffers by parent version control directory: https://github.com/purcell/ibuffer-vc
ReplyDelete