O'Reilly logo

Learning GNU Emacs, Second Edition by Eric S. Raymond, Bill Rosenblatt, Debra Cameron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with Multiple Buffers

You already know how to get into Emacs by typing emacs filename. If you want to create a second buffer that contains a file, simply type C-x C-f to find the file. Emacs automatically creates a second buffer and moves you there. If you already have a copy of the file in a buffer, C-x C-f just moves you to the existing buffer. This move is sensible and probably really what you want anyhow; if C-x C-f read the file from disk every time, you could end up with many versions of the same file that were each slightly different. If the filename you give C-x C-f doesn’t exist, Emacs assumes you want to create a new file by that name and moves you to a blank buffer. (If you make a mistake typing the filename, type C-x C-v to get the right one.)

C-x C-f is always followed by a filename. The command for moving between buffers, C-x b, is followed by a buffer name. Did you realize that the mode line doesn’t display filenames but only buffer names? Some versions of Emacs show both, but GNU shows only the buffer name. The buffer name and the filename, if any, are the same unless you change them (see Section 4.2.3 later in this chapter).

You can do the following with C-x b:

If you type C-x b followed by

Emacs

A new buffer name

Creates a new buffer that isn’t connected with a file and moves there.

The name of an existing buffer

Moves you to the buffer (it doesn’t matter whether the buffer is connected with a file or not).

To move between the buffers, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required