Книга: Learning GNU Emacs, 3rd Edition
4.2.1 Switching Buffers
4.2.1 Switching Buffers
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 Emacs shows only the buffer name. The buffer name and the filename, if any, are the same unless you change them (see the section "Renaming Buffers," later in this chapter).
To move between the buffers, type C-x b. Emacs shows you a default buffer name. Press Enter if that's the buffer you want, or type the first few characters of the correct buffer name and press Tab. Emacs fills in the rest of the name. Now press Enter to move to the buffer.
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). |
If you want to create a second (or third or fourth, etc.) empty buffer, type C-x b. Emacs asks for a buffer name. You can use any name, for example, practice, and press Enter. Emacs creates the buffer and moves you there. For example, assume you've been working on your tried-and-true dickens
buffer. But you'd like something new, so you start a new buffer to play with some prose from James Joyce.
Type: C-x b joyce
You typed a new buffer name.
Type: Enter
Now you have a new buffer named joyce
to type in.
This procedure isn't all that different from using C-x C-f; about the only difference is that the new buffer, joyce
, isn't yet associated with a file. Therefore, if you quit Emacs, the editor won't ask you whether or not you want to save it.
C-x b is especially useful if you don't know the name of the file you are working with. Assume you're working with some obscure file with an unusual name such as .saves-5175-pcp832913pcs.nrockv01.ky.roadrunner.com. Now assume that you accidentally do something that makes this buffer disappear from your screen. How do you get .saves-5175-pcp832913pcs.nrockv01.ky.roadrunner.com back onto the screen? Do you need to remember the entire name or even a part of it? No. Before doing anything else, just type C-x b. The default buffer is the buffer that most recently disappeared; type Enter and you'll see it again.
Alternatively, the Buffer Menu popup lists buffers by major mode, and you can choose one. Hold down Ctrl and click the left mouse button to see a pop-up menu of your current buffers. (The Buffers menu at the top of the screen also shows all current buffers.)
Hold down Ctrl and click the left mouse button.
Emacs displays a pop-up menu of current buffers by mode (Mac OS X).
To cycle through all the buffers you have, type C-x ? to go to the next buffer (in the buffer list) or C-x to go to the previous buffer. (Don't hold down Ctrl while you press the arrow key or Emacs beeps unhappily.)
- 2.2.5. ATM Switching
- 4.2 Working with Multiple Buffers
- Chapter 4. Using Buffers, Windows, and Frames
- 4.1.2 Buffers: Independent of Windows and Frames
- Handling Buffers
- 4.2.2 Deleting Buffers
- 4.5.3 Read-Only Buffers
- 12.4 Editing Comment Buffers
- Vertex Buffers
- Page buffers
- DirectX Tutorial 4: Full Screen and Depth Buffers
- Switching