[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16. Multiple Windows

Emacs can split the frame into two or many windows, which can display parts of different buffers or different parts of one buffer. If you are running XEmacs under X, that means you can have the X window that contains the Emacs frame have multiple subwindows.

16.1 Concepts of Emacs Windows  Introduction to Emacs windows.
16.2 Splitting Windows  New windows are made by splitting existing windows.
16.3 Using Other Windows  Moving to another window or doing something to it.
16.4 Displaying in Another Window  Finding a file or buffer in another window.
16.5 Deleting and Rearranging Windows  Deleting windows and changing their sizes.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.1 Concepts of Emacs Windows

When Emacs displays multiple windows, each window has one Emacs buffer designated for display. The same buffer may appear in more than one window; if it does, any changes in its text are displayed in all the windows that display it. Windows showing the same buffer can show different parts of it, because each window has its own value of point.

At any time, one window is the selected window; the buffer displayed by that window is the current buffer. The cursor shows the location of point in that window. Each other window has a location of point as well, but since the terminal has only one cursor, it cannot show the location of point in the other windows.

Commands to move point affect the value of point for the selected Emacs window only. They do not change the value of point in any other Emacs window, including those showing the same buffer. The same is true for commands such as C-x b to change the selected buffer in the selected window; they do not affect other windows at all. However, there are other commands such as C-x 4 b that select a different window and switch buffers in it. Also, all commands that display information in a window, including (for example) C-h f (describe-function) and C-x C-b (list-buffers), work by switching buffers in a non-selected window without affecting the selected window.

Each window has its own mode line, which displays the buffer name, modification status, and major and minor modes of the buffer that is displayed in the window. See section 1.3 The Mode Line, for details on the mode line.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.2 Splitting Windows

C-x 2
Split the selected window into two windows, one above the other (split-window-vertically).
C-x 3
Split the selected window into two windows positioned side by side (split-window-horizontally).
C-x 6
Save the current window configuration in register reg (a letter).
C-x 7
Restore (make current) the window configuration in register reg (a letter). Use with a register previously set with C-x 6.

The command C-x 2 (split-window-vertically) breaks the selected window into two windows, one above the other. Both windows start out displaying the same buffer, with the same value of point. By default each of the two windows gets half the height of the window that was split. A numeric argument specifies how many lines to give to the top window.

C-x 3 (split-window-horizontally) breaks the selected window into two side-by-side windows. A numeric argument specifies how many columns to give the one on the left. A line of vertical bars separates the two windows. Windows that are not the full width of the frame have truncated mode lines which do not always appear in inverse video, because Emacs display routines cannot display a region of inverse video that is only part of a line on the screen.

When a window is less than the full width, many text lines are too long to fit. Continuing all those lines might be confusing. Set the variable truncate-partial-width-windows to non-nil to force truncation in all windows less than the full width of the frame, independent of the buffer and its value for truncate-lines. See section 4.7 Continuation Lines.

Horizontal scrolling is often used in side-by-side windows. See section 11. Controlling the Display.

You can resize a window and store that configuration in a register by supplying a register argument to window-configuration-to-register (C-x 6). To return to the window configuration established with window-configuration-to-register, use jump-to-register (C-x j).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.3 Using Other Windows

C-x o
Select another window (other-window). That is the letter `o', not zero.
M-C-v
Scroll the next window (scroll-other-window).
M-x compare-windows
Find the next place where the text in the selected window does not match the text in the next window.
M-x other-window-any-frame n
Select the nth different window on any frame.

To select a different window, use C-x o (other-window). That is an `o', for `other', not a zero. When there are more than two windows, the command moves through all the windows in a cyclic order, generally top to bottom and left to right. From the rightmost and bottommost window, it goes back to the one at the upper left corner. A numeric argument, n, moves several steps in the cyclic order of windows. A negative numeric argument moves around the cycle in the opposite order. If the optional second argument which-frames is non-nil, the function cycles through all frames. When the minibuffer is active, the minibuffer is the last window in the cycle; you can switch from the minibuffer window to one of the other windows, and later switch back and finish supplying the minibuffer argument that is requested. See section 6.2 Editing in the Minibuffer.

The command M-x other-window-any-frame also selects the window n steps away in the cyclic order. However, unlike other-window, this command selects a window on the next or previous frame instead of wrapping around to the top or bottom of the current frame, when there are no more windows.

The usual scrolling commands (see section 11. Controlling the Display) apply to the selected window only. M-C-v (scroll-other-window) scrolls the window that C-x o would select. Like C-v, it takes positive and negative arguments.

The command M-x compare-windows compares the text in the current window with the text in the next window. Comparison starts at point in each window. Point moves forward in each window, a character at a time, until the next set of characters in the two windows are different. Then the command is finished.

A prefix argument ignore-whitespace means ignore changes in whitespace. The variable compare-windows-whitespace controls how whitespace is skipped.

If compare-ignore-case is non-nil, changes in case are also ignored.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.4 Displaying in Another Window

C-x 4 is a prefix key for commands that select another window (splitting the window if there is only one) and select a buffer in that window. Different C-x 4 commands have different ways of finding the buffer to select.

C-x 4 b bufname RET
Select buffer bufname in another window. This runs switch-to-buffer-other-window.
C-x 4 f filename RET
Visit file filename and select its buffer in another window. This runs find-file-other-window. See section 14.2 Visiting Files.
C-x 4 d directory RET
Select a Dired buffer for directory directory in another window. This runs dired-other-window. See section 14.9 Dired, the Directory Editor.
C-x 4 m
Start composing a mail message in another window. This runs mail-other-window, and its same-window version is C-x m (see section 25. Sending Mail).
C-x 4 .
Find a tag in the current tag table in another window. This runs find-tag-other-window, the multiple-window variant of M-. (see section 21.11 Tags Tables).

If the variable display-buffer-function is non-nil, its value is the function to call to handle display-buffer. It receives two arguments, the buffer and a flag that if non-nil means that the currently selected window is not acceptable. Commands such as switch-to-buffer-other-window and find-file-other-window work using this function.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.5 Deleting and Rearranging Windows

C-x 0
Get rid of the selected window (delete-window). That is a zero. If there is more than one Emacs frame, deleting the sole remaining window on that frame deletes the frame as well. If the current frame is the only frame, it is not deleted.
C-x 1
Get rid of all windows except the selected one (delete-other-windows).
C-x ^
Make the selected window taller, at the expense of the other(s)
(enlarge-window).
C-x }
Make the selected window wider (enlarge-window-horizontally).

To delete a window, type C-x 0 (delete-window). (That is a zero.) The space occupied by the deleted window is distributed among the other active windows (but not the minibuffer window, even if that is active at the time). Once a window is deleted, its attributes are forgotten; there is no automatic way to make another window of the same shape or showing the same buffer. The buffer continues to exist, and you can select it in any window with C-x b.

C-x 1 (delete-other-windows) is more powerful than C-x 0; it deletes all the windows except the selected one (and the minibuffer). The selected window expands to use the whole frame except for the echo area.

To readjust the division of space among existing windows, use C-x ^ (enlarge-window). It makes the currently selected window longer by one line or as many lines as a numeric argument specifies. With a negative argument, it makes the selected window smaller. C-x } (enlarge-window-horizontally) makes the selected window wider by the specified number of columns. The extra screen space given to a window comes from one of its neighbors, if that is possible; otherwise, all the competing windows are shrunk in the same proportion. If this makes some windows too small, those windows are deleted and their space is divided up. Minimum window size is specified by the variables window-min-height and window-min-width.

You can also resize windows within a frame by clicking the left mouse button on a modeline, and dragging.

Clicking the right button on a mode line pops up a menu of common window manager operations. This menu contains the following options:

Delete Window
Remove the window above this modeline from the frame.

Delete Other Windows
Delete all windows on the frame except for the one above this modeline.

Split Window
Split the window above the mode line in half, creating another window.

Split Window Horizontally
Split the window above the mode line in half horizontally, so that there will be two windows side-by-side.

Balance Windows
Readjust the sizes of all windows on the frame until all windows have roughly the same number of lines.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on August, 3 2012 using texi2html