Emacs: List Buffers

By Xah Lee. Date: . Last updated: .

This page is a tutorial on managing buffers in emacs.

In emacs, every file is shown in a “buffer”. (You can think of “buffer” as opened file or tabbed window without the tab. It's called buffer because back in 1980s, emacs can only display parts of a file.)

Alt+x list-buffersCtrl+x Ctrl+b
List buffers.
Alt+x ibuffer
Improved version of list buffers. It colors the files by type.
Alt+x kill-bufferCtrl+x k
Close the current buffer.
emacs list-buffers 2021-07-20
emacs list-buffers 2021-07-20
emacs ibuffer 2021-07-20
emacs ibuffer 2021-07-20

Make ibuffer Default

To make ibuffer default, put the following in your init file:

(defalias 'list-buffers 'ibuffer) ; make ibuffer default

Batch Operation on Buffers

You can do operation in batch to the marked ones. Example:

Here's most useful ibuffer commands.

In ibuffer, the key sequence * u S D will save all unsaved files and close them. This is particularly useful after you've done a find replace on hundreds of files with dired-do-query-replace-regexp. [see Emacs: Find Replace Text in Directory]

While in ibuffer, Alt+x describe-mode to see a full list of ibuffer commands.

Emacs Manage Buffers

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Tutorial

Quick Start

Manage Windows

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc