When you have many buffers opened, they are all shown in the buffer list.

Are they shown in the order of visit, from the latest to the remotest?

Can we organize the buffers in the buffer list somehow? For example resort them by their pathnames?


I assume you are referring to the list of buffers you get with the default key binding C-x C-b, which calls list-buffers. That command uses Buffer-menu-mode which provides some key bindings for working with the list but has limited options for sorting or filtering. For more detail on what you can do in the list, try C-h f Buffer-menu-mode.

Emacs includes a more powerful buffer list that you may prefer: ibuffer. This mode provides a similar list of open buffers, but with additional capabilities for sorting, filtering, grouping, and otherwise working with the list. You can try it out with M-x ibuffer, and if you like it you can add this to your Emacs init file to use ibuffer instead of the default list-buffers command:

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

The easiest way to get started with ibuffer is to explore the menu. Look under 'View' for options to sort, filter, and mark buffers.


Use C-h m in the buffer-list buffer to get answers to these questions and more. You can click the header of a column to resort entries by that column. Click it again to reverse. To sort by pathname, click header File.

If you don't have a mouse then move the cursor under the column you want to sort and use S to sort it. Repeat to reverse the direction.

If you use C-h m then near the beginning of the description of the mode you see See buffer-menu for a description of its contents. Follow that link (using RET, aka Enter) to see more info about the mode.

Near the end of that page of information you see this: See Buffer-menu-mode for the keybindings available the Buffer Menu. If you follow that link then near the top of the next page of info (about Buffer-menu-mode) you see this: Parent mode: tabulated-list-mode. If you follow that link, to see info about the parent mode, there you will see additional keys that are available in Buffer-menu-mode - keys that are not specific to it but are provided by its parent mode, tabulated-list-mode.

Among those key descriptions you see this:

S       tabulated-list-sort

That tells you that the key S runs command tabulated-list-sort. If you follow that link then you see this:

tabulated-list-sort is an interactive compiled Lisp function in

(tabulated-list-sort &optional N)

Sort Tabulated List entries by the column at point.
With a numeric prefix argument N, sort the Nth column.

It's a bit roundabout, but this tells you that if you put the cursor ( point is the cursor position) in a given column and you hit S then you will sort the buffer according to that column.

The main lesson is that C-h m gives you information about the current mode, whatever mode you are in. In that description, you can follow links to get more information.

  • Thanks. I am under text terminal, so clicking by a mouse doesn't work. – Tim Feb 10 '16 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.