Emacs Buffer Navigation
100%

Advanced Text-Fu · Lesson 11

Emacs Buffer Navigation

Learn how to switch and kill Emacs buffers while splitting, selecting, and closing display windows.

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.

Which 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.

Which 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.

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

Which 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.

Which 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.

Lesson complete

You finished Emacs Buffer Navigation

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

  • Switch buffers in the selected window with C-x b.

  • Split below with C-x 2 or to the right with C-x 3.

  • Select another window with C-x o.

  • Remove window displays with C-x 0 or C-x 1.

  • Kill a buffer with C-x k only after reviewing unsaved changes.

Keep your learning progress

Create a free account to save this lesson and continue learning on any device.

Create a free account
Next Lesson
Back to Advanced Text-Fu