428
+ − 1
+ − 2 @node Windows, Mule, Buffers, Top
+ − 3 @chapter Multiple Windows
+ − 4 @cindex windows
+ − 5
+ − 6 Emacs can split the frame into two or many windows, which can display
+ − 7 parts of different buffers or different parts of one buffer. If you are
+ − 8 running XEmacs under X, that means you can have the X window that contains
444
+ − 9 the Emacs frame have multiple subwindows.
428
+ − 10
+ − 11 @menu
+ − 12 * Basic Window:: Introduction to Emacs windows.
+ − 13 * Split Window:: New windows are made by splitting existing windows.
+ − 14 * Other Window:: Moving to another window or doing something to it.
+ − 15 * Pop Up Window:: Finding a file or buffer in another window.
+ − 16 * Change Window:: Deleting windows and changing their sizes.
+ − 17 @end menu
+ − 18
+ − 19 @node Basic Window, Split Window, Windows, Windows
+ − 20 @section Concepts of Emacs Windows
+ − 21
+ − 22 When Emacs displays multiple windows, each window has one Emacs
+ − 23 buffer designated for display. The same buffer may appear in more
+ − 24 than one window; if it does, any changes in its text are displayed in all
+ − 25 the windows that display it. Windows showing the same buffer can
+ − 26 show different parts of it, because each window has its own value of point.
+ − 27
+ − 28 @cindex selected window
+ − 29 At any time, one window is the @dfn{selected window}; the buffer
+ − 30 displayed by that window is the current buffer. The cursor
+ − 31 shows the location of point in that window. Each other window has a
+ − 32 location of point as well, but since the terminal has only one cursor, it
444
+ − 33 cannot show the location of point in the other windows.
428
+ − 34
+ − 35 Commands to move point affect the value of point for the selected Emacs
+ − 36 window only. They do not change the value of point in any other Emacs
+ − 37 window, including those showing the same buffer. The same is true for commands
+ − 38 such as @kbd{C-x b} to change the selected buffer in the selected window;
+ − 39 they do not affect other windows at all. However, there are other commands
+ − 40 such as @kbd{C-x 4 b} that select a different window and switch buffers in
+ − 41 it. Also, all commands that display information in a window, including
+ − 42 (for example) @kbd{C-h f} (@code{describe-function}) and @kbd{C-x C-b}
+ − 43 (@code{list-buffers}), work by switching buffers in a non-selected window
+ − 44 without affecting the selected window.
+ − 45
+ − 46 Each window has its own mode line, which displays the buffer name,
+ − 47 modification status, and major and minor modes of the buffer that is
+ − 48 displayed in the window. @xref{Mode Line}, for details on the mode
+ − 49 line.
+ − 50
+ − 51 @node Split Window, Other Window, Basic Window, Windows
+ − 52 @section Splitting Windows
+ − 53
+ − 54 @table @kbd
+ − 55 @item C-x 2
+ − 56 Split the selected window into two windows, one above the other
+ − 57 (@code{split-window-vertically}).
+ − 58 @item C-x 3
+ − 59 Split the selected window into two windows positioned side by side
+ − 60 (@code{split-window-horizontally}).
+ − 61 @item C-x 6
+ − 62 Save the current window configuration in register @var{reg} (a letter).
+ − 63 @item C-x 7
+ − 64 Restore (make current) the window configuration in register
+ − 65 @var{reg} (a letter). Use with a register previously set with @kbd{C-x 6}.
+ − 66 @end table
+ − 67
+ − 68 @kindex C-x 2
+ − 69 @findex split-window-vertically
+ − 70 The command @kbd{C-x 2} (@code{split-window-vertically}) breaks the
+ − 71 selected window into two windows, one above the other. Both windows
+ − 72 start out displaying the same buffer, with the same value of point. By
+ − 73 default each of the two windows gets half the height of the window that
+ − 74 was split. A numeric argument specifies how many lines to give to the
+ − 75 top window.
+ − 76
+ − 77 @kindex C-x 3
+ − 78 @findex split-window-horizontally
+ − 79 @kbd{C-x 3} (@code{split-window-horizontally}) breaks the selected
+ − 80 window into two side-by-side windows. A numeric argument specifies how
+ − 81 many columns to give the one on the left. A line of vertical bars
+ − 82 separates the two windows. Windows that are not the full width of the
+ − 83 frame have truncated mode lines which do not always appear in inverse
+ − 84 video, because Emacs display routines cannot display a region of inverse
+ − 85 video that is only part of a line on the screen.
+ − 86
+ − 87 @vindex truncate-partial-width-windows
+ − 88 When a window is less than the full width, many text lines are too
+ − 89 long to fit. Continuing all those lines might be confusing. Set the
+ − 90 variable @code{truncate-partial-width-windows} to non-@code{nil} to
+ − 91 force truncation in all windows less than the full width of the frame,
+ − 92 independent of the buffer and its value for @code{truncate-lines}.
+ − 93 @xref{Continuation Lines}.@refill
+ − 94
+ − 95 Horizontal scrolling is often used in side-by-side windows.
+ − 96 @xref{Display}.
+ − 97
+ − 98 @findex jump-to-register
+ − 99 @findex window-configuration-to-register
+ − 100 You can resize a window and store that configuration in a register by
+ − 101 supplying a @var{register} argument to @code{window-configuration-to-register}
+ − 102 (@kbd{C-x 6}). To return to the window configuration established with
+ − 103 @code{window-configuration-to-register}, use @code{jump-to-register}
+ − 104 (@kbd{C-x j}).
+ − 105
+ − 106 @node Other Window, Pop Up Window, Split Window, Windows
+ − 107 @section Using Other Windows
+ − 108
+ − 109 @table @kbd
+ − 110 @item C-x o
+ − 111 Select another window (@code{other-window}). That is the letter `o', not zero.
+ − 112 @item M-C-v
+ − 113 Scroll the next window (@code{scroll-other-window}).
+ − 114 @item M-x compare-windows
+ − 115 Find the next place where the text in the selected window does not match
+ − 116 the text in the next window.
+ − 117 @item M-x other-window-any-frame @var{n}
+ − 118 Select the @var{n}th different window on any frame.
+ − 119 @end table
+ − 120
+ − 121 @kindex C-x o
+ − 122 @findex other-window
+ − 123 To select a different window, use @kbd{C-x o} (@code{other-window}).
+ − 124 That is an `o', for `other', not a zero. When there are more than
+ − 125 two windows, the command moves through all the windows in a cyclic
+ − 126 order, generally top to bottom and left to right. From the rightmost
+ − 127 and bottommost window, it goes back to the one at the upper left corner.
+ − 128 A numeric argument, @var{n}, moves several steps in the cyclic order of
+ − 129 windows. A negative numeric argument moves around the cycle in the
444
+ − 130 opposite order. If the optional second argument @var{which-frames} is
428
+ − 131 non-@code{nil}, the function cycles through all frames. When the
+ − 132 minibuffer is active, the minibuffer is the last window in the cycle;
+ − 133 you can switch from the minibuffer window to one of the other windows,
+ − 134 and later switch back and finish supplying the minibuffer argument that
+ − 135 is requested. @xref{Minibuffer Edit}.
+ − 136
+ − 137 @findex other-window-any-frame
+ − 138 The command @kbd{M-x other-window-any-frame} also selects the window
+ − 139 @var{n} steps away in the cyclic order. However, unlike @code{other-window},
+ − 140 this command selects a window on the next or previous frame instead of
+ − 141 wrapping around to the top or bottom of the current frame, when there
+ − 142 are no more windows.
+ − 143
+ − 144 @kindex C-M-v
+ − 145 @findex scroll-other-window
+ − 146 The usual scrolling commands (@pxref{Display}) apply to the selected
+ − 147 window only. @kbd{M-C-v} (@code{scroll-other-window}) scrolls the
+ − 148 window that @kbd{C-x o} would select. Like @kbd{C-v}, it takes positive
444
+ − 149 and negative arguments.
428
+ − 150
+ − 151 @findex compare-windows
+ − 152 The command @kbd{M-x compare-windows} compares the text in the current
+ − 153 window with the text in the next window. Comparison starts at point in each
+ − 154 window. Point moves forward in each window, a character at a time,
+ − 155 until the next set of characters in the two windows are different. Then the
+ − 156 command is finished.
+ − 157
+ − 158 A prefix argument @var{ignore-whitespace} means ignore changes in
+ − 159 whitespace. The variable @code{compare-windows-whitespace} controls how
+ − 160 whitespace is skipped.
+ − 161
+ − 162 If @code{compare-ignore-case} is non-@code{nil}, changes in case are
+ − 163 also ignored.
+ − 164
+ − 165 @node Pop Up Window, Change Window, Other Window, Windows
+ − 166 @section Displaying in Another Window
+ − 167
+ − 168 @kindex C-x 4
+ − 169 @kbd{C-x 4} is a prefix key for commands that select another window
+ − 170 (splitting the window if there is only one) and select a buffer in that
+ − 171 window. Different @kbd{C-x 4} commands have different ways of finding the
+ − 172 buffer to select.
+ − 173
+ − 174 @findex switch-to-buffer-other-window
+ − 175 @findex find-file-other-window
+ − 176 @findex find-tag-other-window
+ − 177 @findex dired-other-window
+ − 178 @findex mail-other-window
+ − 179 @table @kbd
+ − 180 @item C-x 4 b @var{bufname} @key{RET}
444
+ − 181 Select buffer @var{bufname} in another window. This runs
428
+ − 182 @code{switch-to-buffer-other-window}.
+ − 183 @item C-x 4 f @var{filename} @key{RET}
+ − 184 Visit file @var{filename} and select its buffer in another window. This
+ − 185 runs @code{find-file-other-window}. @xref{Visiting}.
+ − 186 @item C-x 4 d @var{directory} @key{RET}
+ − 187 Select a Dired buffer for directory @var{directory} in another window.
+ − 188 This runs @code{dired-other-window}. @xref{Dired}.
+ − 189 @item C-x 4 m
+ − 190 Start composing a mail message in another window. This runs
+ − 191 @code{mail-other-window}, and its same-window version is @kbd{C-x m}
+ − 192 (@pxref{Sending Mail}).
+ − 193 @item C-x 4 .
+ − 194 Find a tag in the current tag table in another window. This runs
+ − 195 @code{find-tag-other-window}, the multiple-window variant of @kbd{M-.}
+ − 196 (@pxref{Tags}).
+ − 197 @end table
+ − 198
+ − 199 @vindex display-buffer-function
+ − 200 If the variable @code{display-buffer-function} is non-@code{nil}, its value is
+ − 201 the function to call to handle @code{display-buffer}. It receives two
+ − 202 arguments, the buffer and a flag that if non-@code{nil} means that the
+ − 203 currently selected window is not acceptable. Commands such as
+ − 204 @code{switch-to-buffer-other-window} and @code{find-file-other-window}
+ − 205 work using this function.
+ − 206
+ − 207 @node Change Window,, Pop Up Window, Windows
+ − 208 @section Deleting and Rearranging Windows
+ − 209
+ − 210 @table @kbd
+ − 211 @item C-x 0
444
+ − 212 Get rid of the selected window (@code{delete-window}). That is a zero.
428
+ − 213 If there is more than one Emacs frame, deleting the sole remaining
+ − 214 window on that frame deletes the frame as well. If the current frame
444
+ − 215 is the only frame, it is not deleted.
428
+ − 216 @item C-x 1
+ − 217 Get rid of all windows except the selected one
+ − 218 (@code{delete-other-windows}).
+ − 219 @item C-x ^
+ − 220 Make the selected window taller, at the expense of the other(s)
+ − 221 @*(@code{enlarge-window}).
+ − 222 @item C-x @}
+ − 223 Make the selected window wider (@code{enlarge-window-horizontally}).
+ − 224 @end table
+ − 225
+ − 226 @kindex C-x 0
+ − 227 @findex delete-window
+ − 228 To delete a window, type @kbd{C-x 0} (@code{delete-window}). (That is a
+ − 229 zero.) The space occupied by the deleted window is distributed among the
+ − 230 other active windows (but not the minibuffer window, even if that is active
+ − 231 at the time). Once a window is deleted, its attributes are forgotten;
+ − 232 there is no automatic way to make another window of the same shape or
+ − 233 showing the same buffer. The buffer continues to exist, and you can
+ − 234 select it in any window with @kbd{C-x b}.
+ − 235
+ − 236 @kindex C-x 1
+ − 237 @findex delete-other-windows
+ − 238 @kbd{C-x 1} (@code{delete-other-windows}) is more powerful than @kbd{C-x 0};
+ − 239 it deletes all the windows except the selected one (and the minibuffer).
+ − 240 The selected window expands to use the whole frame except for the echo
+ − 241 area.
+ − 242
+ − 243 @kindex C-x ^
+ − 244 @findex enlarge-window
+ − 245 @kindex C-x @}
+ − 246 @findex enlarge-window-horizontally
+ − 247 @vindex window-min-height
+ − 248 @vindex window-min-width
+ − 249 To readjust the division of space among existing windows, use @kbd{C-x
+ − 250 ^} (@code{enlarge-window}). It makes the currently selected window
+ − 251 longer by one line or as many lines as a numeric argument specifies.
+ − 252 With a negative argument, it makes the selected window smaller.
+ − 253 @kbd{C-x @}} (@code{enlarge-window-horizontally}) makes the selected
+ − 254 window wider by the specified number of columns. The extra screen space
+ − 255 given to a window comes from one of its neighbors, if that is possible;
+ − 256 otherwise, all the competing windows are shrunk in the same proportion.
+ − 257 If this makes some windows too small, those windows are deleted and their
+ − 258 space is divided up. Minimum window size is specified by the variables
+ − 259 @code{window-min-height} and @code{window-min-width}.
+ − 260
+ − 261 You can also resize windows within a frame by clicking the left mouse
+ − 262 button on a modeline, and dragging.
+ − 263
+ − 264 Clicking the right button on a mode line pops up a menu of common window
+ − 265 manager operations. This menu contains the following options:
+ − 266
+ − 267 @cindex Windows menu
+ − 268 @cindex Pull-down Menus
+ − 269 @cindex menus
+ − 270 @table @b
+ − 271 @item Delete Window
+ − 272 Remove the window above this modeline from the frame.
+ − 273
+ − 274 @item Delete Other Windows
+ − 275 Delete all windows on the frame except for the one above this modeline.
+ − 276
+ − 277 @item Split Window
+ − 278 Split the window above the mode line in half, creating another window.
+ − 279
+ − 280 @item Split Window Horizontally
+ − 281 Split the window above the mode line in half horizontally, so that there
+ − 282 will be two windows side-by-side.
+ − 283
+ − 284 @item Balance Windows
+ − 285 Readjust the sizes of all windows on the frame until all windows have
+ − 286 roughly the same number of lines.
+ − 287 @end table