First, define the concept of the Emacs window. Double-click the Emacs icon to open it.ProgramThe Windows window is called frame, which contains the title bar, menu bar, toolbar, bottom mode line, and echo area. The window is the area where a large part of text is displayed, in fact, each window has its own mode line. In this article, I will refer to frame as a box and window as a window, which is a little different from what we usually understand in windows.
In Emacs, a box can be divided into multiple windows. Multiple windows can display the same or different buffer, but one window can only belong to one frame. A window can only display one buffer, but the two windows can also display different parts of a buffer. These two windows are synchronized, that is, if you modify the buffer in a window, it can be displayed immediately in another window. However, moving the cursor in one window does not affect the other window. Multi-buffer has the concept of current buffering. for multiple windows, the current window also exists. The mode line of the selected window is darker than that of other windows.
1. display window
CommandC-x 2(Split-window-verticallyVertical Split Window: divides the upper and lower windows into two types. The split window displays the Current Buffer by default. You can use this command multiple times to keep a window evenly. Corresponding commands for Horizontal Split windowsC-x 3(Split-window-horizontally), These two commands can also be used together. It is not impossible to draw a maze on the screen. The split command can also add parameters, such as M-5 C-x 2 that is to say that the above window occupies only 5 lines, the rest of the location are given to the following window.
C-x O(Other-Window) You can switch from top to bottom in multiple windows. Use parameters to control the selection of the following windows. If you want to select a back window, set the parameter to negative.
C-m-V(Scroll-other-Window) To scroll down the next window.
In the previous chapter, we can see that some commands are prefixed with C-x 4. These commands are used to operate on multiple windows.
C-x 4 BBufname(Switch-to-buffer-other-Window) Open the buffer in another window.
C-x 4 C-oBufname(Display-Buffer) Open the buffer in another window, but do not select that window.
C-x 4 fFilename(Find-file-other-Window) Open the file in another window.
C-x 4 d Directory(Dired-other-Window) Open the folder in another window.
C-x 4 m(Mail-other-WindowIn another window.
C-x 4 R Filename(Find-file-read-only-other-Window) Open the file in read-only mode in another window.
By default, commands of this type are vertically split windows.
Ii. Rearranging windows
The window is very difficult to use.C-x 0(Delete-Window) To close the current window. Note that the window and buffer are two concepts. Closing a window does not affect the buffer, or the file we are editing. You can also useC-X 1(Delete-other-Windows) Close all other windows. If you want to disable the buffer when the window is openedC-x 4 0(Kill-buffer-and-Window).
We can also change the window size:C-x ^(Enlarge-Window) To make the window high,C-X {(Shrink-window-horizontally) Narrowing the window.C-x}(Enlarge-window-horizontally),C-X-(Shrink-window-if-larger-than-Buffer) This can be understood literally. If the window is larger than the buffer, it will be reduced,C-x +(Balance-Windows) This command has nothing to do with the previous one. It makes all windows as high.
Finally, let's talk about a command to switch in the window. Sometimes the window is too open to remember the order, and it will be very troublesome to use C-x O. There is a type of command that allows you to switch the current window from top to bottom,M-x windmove-RightThat is, the window to the right, corresponding to "Left", "up", "down", can be moved to four directions.
I wrote ten chapters without knowing it. Although it was a little slow, I persisted and continued to work hard!
Summary:
Buttons |
Command |
Function |
C-x 2
|
Split-window-vertically |
Vertical Split Window |
C-x 3
|
Split-window-horizontally |
Horizontal Split Window |
C-x O
|
Other-Window |
Select next window |
C-m-V
|
Scroll-other-Window |
Scroll down the next window |
C-x 4 B |
Switch-to-buffer-other-Window |
Open a buffer in another window |
C-x 4 C-o |
Display-Buffer |
Open the buffer in another window, but do not select |
C-x 4 f |
Find-file-other-Window |
Open a file in another window |
C-x 4 d |
Dired-other-Window |
Open a folder in another window |
C-x 4 m |
Mail-other-Window |
Write an email in another window |
C-x 4 R |
Find-file-read-only-other-Window |
Open the file in read-only mode in another window |
C-x 0 |
Delete-Window |
Close current window |
C-X 1 |
Delete-other-Windows |
Close other windows |
C-x 4 0 |
Kill-buffer-and-Window |
Close current window and Buffer |
C-x ^ |
Enlarge-Window |
Increase current window |
C-X { |
Shrink-window-horizontally |
Narrowing the current window |
C-x} |
Enlarge-window-horizontally |
Widening the current window |
C-X- |
Shrink-window-if-larger-than-Buffer |
The window size is smaller than the buffer size. |
C-x + |
Balance-Windows |
All windows are as high |
|
Windmove-Right |
Switch to the right window (for example, up, down, left) |
Not complete...