Search code examples
emacs

How can I get back the "natural" order in the Buffer List?


With C-x C-b the buffer list is displayed. First in it's natural order with most recently used buffers on top, and buried buffers at the bottom.

There, I can now sort the Buffer by name, size, mode and file. But once I click on such an option I cannot go back to the original ordering.

Also killing the buffer and recreating it does not change that order. (Using 25.2)

So how can I get that ordering back without restarting emacs?


Solution

  • There is another mode that's nowadays built-in to Emacs that can be used to display the buffer list: ibuffer-mode.

    If you are not using it already, you can experiment with M-x ibuffer and find out its capabilities with C-h m. Note that in particular, it can sort the buffer list in various ways, one of which is by recency with s v, which is what the OP asked for; but note also that it has many other ways to sort that make it very flexible.

    Once you are convinced that that's the way to go, you can redefine the C-x C-b keybinding in your init file with:

    (global-set-key (kbd "C-x C-b") 'ibuffer)
    

    I did that a long time ago and have never looked back. IMO, it should be the default: that may come to pass, but AFAIK that is still not the case.