EmacsWiki: Buffer (original) (raw)

(This is a glossary page. It is not for how-to information.)

An Emacs buffer is similar to what other systems might call a file, document, workspace or editor. A buffer can contain text and images.

Buffers are shown in windows on the screen. A buffer can be displayed in more than one window at a time, or it might not be displayed at all.

At the bottom of each window is a ModeLine that describes the buffer and its state. Every buffer has a unique buffer name; the name is shown in the mode-line.

By default, visiting a file puts the file content into a buffer and displays it in a window. By default, the buffer name is based on the (relative) file name.

Saving a buffer writes it to its visited file.

Killing a buffer discards its contents. By default, Emacs prompts you if there are unsaved changes.

By convention, buffers whose names start with an asterisk (*) are not associated with files. For example, by default Emacs starts with an empty buffer named *scratch*. If such buffers have unsaved changes when you exit Emacs, these buffers are discarded without asking.

Buffers whose names start with a space are invisible, which means they are hidden from many operations. These buffers are typically created and used by Emacs for internal purposes.

Buffer Commands and Their Keys

Key Meaning Command
C-x C-f Find and visit a file find-file
C-x C-r Visit a file in read-only mode find-file-read-only
C-x C-s Save the current buffer to its file save-buffer
C-x C-w Save the current buffer contents to a file you specify (Save As) write-file
C-x k Kill a buffer you name kill-buffer
C-x b Switch to editing a buffer you specify switch-to-buffer
C-x C-b Open the BufferMenu list-buffers

See Also


CategoryGlossary