The buffer menu lists the [[buffer]]s (files and such) open in Emacs.  It appears when you press `C-x C-b'.

The buffer menu is itself a buffer, with its own MajorMode (called `Buffer-menu' in code, and displayed as ##Buffer Menu## in the ModeLine).

The buffer menu should not be confused with the "Buffers" menu (note the plural) that appears in the pull-down menu bar.  Both allow switching buffers, but the buffer menu has several other features.  The "Buffers" pull-down menu has an item, ''List All Buffers'', which opens the buffer menu.

== Appearance ==

Screenshot of the buffer menu as it appears in Emacs 27.1 (released 2020 August):

[[image:BufferMenuScreenShot]]

Note the HeaderLine with column headings at the top of the window.  Clicking a header will [[BufferMenuSorting|sort]] by that field.

Characters at the left are status indicators.  In this example, the most recent buffer is ##pathclip.el##, as indicated by a dot (##.##) in the first column; that buffer has also been modified (per the ##*##).  The ##init.el## buffer has been modified, and further, marked for saving (##S##).  Two more files -- ##template_ckfiles## and ##README## -- have been marked for viewing (##>##).  The two EmacsLisp files (##.el.gz##) have been marked for kill (close) as shown by ##D##.



== Columns ==

The buffer menu consists of several columns (a ''tabulated list'' in Emacs-speak).  The default columns, with their positions, headings, and purpose, are:

|| Heading || # || Meaning ||
|| C       || 0        || ##>## if marked to display, ##D## if marked to kill, ##.## if current ||
|| R       || 1        || ##%## if read-only ||
|| M       || 2        || ##*## if modified, ##S## if marked to save  ||
|| Buffer  || 3        || Name of the buffer (not always the file) ||
|| Size    || 4        || Length in bytes ||
|| Mode    || 5        || MajorMode ||
|| File    || 6        || Full path and name of file, if any ||

The "current" buffer is the most recently used (displayed) buffer, other than the buffer menu itself.

The column number is important for BufferMenuSorting.

== Opening the buffer menu ==

By default, `C-x C-b' opens a new window, and displays the buffer menu in that window.  You need to switch to that window (e.g., with `C-x o') before you can use it.

To have it instead open the buffer menu ''and switch to it'' in one action, rebind the key as follows:

    (global-set-key (kbd "C-x C-b") 'buffer-menu-other-window)

To just open the buffer menu in the current window (burying whatever buffer you were in before):

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

== Enhancements ==

Enhancements to vanilla buffer menu.  Some of these may be obsolete in modern Emacs.

* IbufferMode - enhanced BufferMenu with more Dired-like features (included in Emacs since version 22)
* [[BufferMenu+]] -- Highlighting using local faces. More commands. Better sorting. New columns. Column width resizing.
* BufferMenuHighlighting -- Highlighting using font-lock faces.
* BufferMenuSorting -- Sorting the listing in buffer menu.
* FixBuffersList -- New modification status and colors in buffers list.

=== Open in different frame ===

Open in a different frame (from ##smoke_## on ###emacs##):

        (defun Buffer-menu-other-frame ()
          (interactive)
          (switch-to-buffer-other-frame (Buffer-menu-buffer t)))
    
        (define-key Buffer-menu-mode-map "5"
           'Buffer-menu-other-frame)

=== Rename buffer at point ===

        (defun Buffer-menu-rename-buffer (newname)
          "Rename buffer at line in window."
          (interactive
           (list (read-buffer "Rename buffer (to new name): "
                              (buffer-name (Buffer-menu-buffer t)))))
          (with-current-buffer (Buffer-menu-buffer t)
            (rename-buffer newname))
          (revert-buffer))
        
        (define-key Buffer-menu-mode-map "R" 'Buffer-menu-rename-buffer)

== History ==

In the past, there were variations on the buffer menu.  `list-buffers' came first, and presented a simple list, allowing you to pick a buffer to switch to, and little else.

Various non-standard enhancements (some listed on this page) were developed to add capabilities.

Later, a standard `buffer-menu' was added, which let you manipulate buffers.  `C-x C-b' remained bound to the simpler `list-buffers` for a time.  The relation between `list-buffers' and `buffer-menu' was a bit like that between `list-directories' (`C-x C-d') and `dired' (`C-x d'): One for listing, the other for listing and manipulating.

Eventually the older, simpler `list-buffers` was retired.  Since circa Emacs 22, `list-buffers`, `buffer-menu', and `C-x C-b' all do the same thing.

== See also ==

* In the EmacsManual:
** [[Manual:List Buffers]]
** [[Manual:Several Buffers]]
* SwitchingBuffers

----
CategoryBufferSwitching
