Advanced Text-Fu · Lesson 11 of 13

Emacs Buffer Navigation

0 / 5 checkpoints answered

Full screen ↗

An Emacs buffer holds text or editor state, while a window displays a buffer. A buffer can exist without being visible, and several windows can display one buffer. Managing one object does not automatically manage the other.

Switching Buffers

Use C-x b, which runs switch-to-buffer, to select a buffer by name in the current window:

C-x b

The minibuffer offers completion for existing names. Entering a new name can create a non-file buffer with that name; it does not visit a file pathname.

By default, C-x Right runs next-buffer and C-x Left runs previous-buffer, cycling through buffers in the selected window.

CheckWhich key sequence prompts for a buffer name to display in the current window?

Splitting the Selected Window

Use C-x 2 to split the selected window into an upper and lower window:

C-x 2

Use C-x 3 to split it into left and right windows:

C-x 3

The new window initially displays a buffer, often the same one. Switch buffers in either window independently.

CheckWhich key sequence splits the selected Emacs window into left and right windows?

Selecting and Closing Windows

Use C-x o, which runs other-window, to select the next window:

C-x o

Use these commands to remove window displays:

  • C-x 0: Delete the selected window.
  • C-x 1: Delete the other windows in the current frame.

Deleting a window normally leaves its displayed buffer alive. You can show that buffer again in another window.

CheckWhich key sequence moves point and keyboard focus to another Emacs window?

CheckWhich key sequence keeps the selected window and deletes the other windows in its frame?

Killing a Buffer

Use C-x k, which runs kill-buffer, to prompt for a buffer to remove from Emacs:

C-x k

The current buffer is the default choice. If a file-visiting buffer has unsaved changes, Emacs warns before killing it. Read the prompt; killing a modified buffer can discard edits.

Killing a buffer is different from deleting a window. Emacs replaces a killed buffer in any displaying window, while deleting a window can leave its buffer untouched.

CheckWhich key sequence prompts to kill an Emacs buffer?

Practice these commands with *scratch* and disposable buffers. Before killing any file-visiting buffer, confirm whether its modified indicator shows unsaved work.

Summary

You can now manage what Emacs stores and what each window displays.

  1. Switch buffers in the selected window with C-x b.
  2. Split below with C-x 2 or to the right with C-x 3.
  3. Select another window with C-x o.
  4. Remove window displays with C-x 0 or C-x 1.
  5. Kill a buffer with C-x k only after reviewing unsaved changes.