You can create horizontal windows or vertical windows or both, but personally we place vertical windows with the more advanced esoterica near the end of the chapter. Here we'll discuss creating horizontal windows, finding a file in a new window, and deleting windows.
4.3.1 Creating Horizontal Windows
The most commonly used window command is C-x 2(for split-window-vertically). This command splits the current window into two, horizontally oriented windows. You can repeat this command to split the screen into more horizontal windows.
Initial state:

Editing our trusty dickens
buffer.
Type: C-x 2

The screen is divided into two horizontal windows; the mode line demarcates each window.
You can also have Emacs set up windows for you when you start a session. If you want to edit two files in horizontal windows, specify their filenames when you start Emacs at a command prompt. For example, if you wanted to edit dickens and joyce , you would type emacs dickens joyceand Emacs would display these files in two horizontal windows. If you try this with more than two files, Emacs displays two horizontal windows, with a file in one and a list of buffers in the other.
A number of the "other window" commands are just the ordinary command with a 4 inserted in it. For example, to find a file in another window, type C-x 4 f. (If only one window is currently open, Emacs opens another one.) To select a different buffer in another window, type C-x 4 b. Many users find these commands preferable to the normal C-x C-fand C-x bcommands because they save you a step: you need not move to the window, give a command, and move back.
Once you've got multiple windows open, it's helpful to be able to scroll them without moving there. To scroll the other window, type C-M-v.
4.3.2 Moving Between Windows
To move from one window to another, type C-x o( ostands for other in this command). If you have more than two windows displayed, Emacs moves from one to the next. There's no way to specify which window to move to, so you may have to type C-x oa few times to get to the one you want if you have more than two windows displayed. (You can also click your mouse in a window if you're using the GUI version.)
Now that you can create windows and can move between them, what else can you do? Practically anything. With our two windows on dickens open, one on top of the other. Initially, both of these windows are looking at the same file.
Type: C-x 2

Two windows open on dickens
.
We can give any editing commands we want within either window. We can move back and forth in one window without affecting the other. Let's see what happens if we want to edit another file.
Type: C-x C-f blake

Now you have two windows, two buffers, and two files.
By using C-x o, we can edit one file and then the other. We can kill text from one buffer and yank it back in another. For example, let's move the first line of Blake's poem to the top of the dickens buffer.
Type: C-k C-k C-x o M-< C-y Enter

The Blake text has been yanked into the dickens
buffer.
Editing with multiple buffers in separate windows is particularly useful if, for example, you want to copy material from one file to another or if you want to read a file containing reference material while editing another. Programmers often need to look at several different files at the same time—for example, a header file and a code file, or a function call site and the routine that's being called. Once you get used to the commands for moving between different windows, you may spend most of your time with two or three windows on your screen.
4.3.3 Getting Rid of Windows
Deleting a window only means that it isn't displayed anymore; it doesn't delete any of the information or any of your unsaved changes. The underlying buffer is still there, and you can switch to it using C-x b. To delete the window you're in, type C-x 0(zero). If you want to delete all windows but the one you're working on, type C-x 1(one), meaning "make this my one and only window." As you'd expect, the remaining window "grows" to fill up the rest of the space. You can also delete all windows on a certain buffer by typing: M-x delete-windows-on Enter buffername
Enter.
By now you know that Emacs calls GUI windows "frames." In this section, we'll cover how to create frames, navigate between frames, and delete frames.
4.4.1 Creating a New Frame
To open a new frame, type C-x 5 2(for make-frame). Emacs makes a new frame containing the current buffer and puts it on top of the current frame.
If your new frame completely overlaps your current frame, you may need to size the new frame to tell them apart. For a more convenient solution, add these lines to your .emacs file:
(setq initial-frame-alist '((top . 10) (left . 30)
(width . 90) (height . 50)))
(setq default-frame-alist '((width . 80) (height . 45)))
These lines set up sizes for the width and height of Emacs frames. The first frame is the size set in initial-frame-alist(in this example, 90 characters wide by 50 lines high with top and left defining an inset), and subsequent frames, specified by default-frame-alist, will be 80 characters wide and 45 lines high. Depending on your display, you can make these numbers smaller or larger.
Here we edit a bit of Henry James.
Type: C-x 5 2

Emacs opens a new frame titled james
Frame Names
Note the title of your new frame. The first frame in your session, your initial Emacs frame, displays Emacs@ system name
at the top (or Emacs's best guess at the system name). Any other frames you create display the buffer name at the top. In fact, once you have multiple frames, all frames display the buffer name as their title. If you delete all frames but one, the title once again reverts to Emacs@ system name
.
Let's say we want to open a frame on our dickens
buffer.
Type: C-x 5 f dickens Enter

Читать дальше