25829
|
1 @c This is part of the Emacs manual.
|
|
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
|
|
3 @c See file emacs.texi for copying conditions.
|
|
4 @node Windows, Frames, Buffers, Top
|
|
5 @chapter Multiple Windows
|
|
6 @cindex windows in Emacs
|
|
7 @cindex multiple windows in Emacs
|
|
8
|
|
9 Emacs can split a frame into two or many windows. Multiple windows
|
|
10 can display parts of different buffers, or different parts of one
|
|
11 buffer. Multiple frames always imply multiple windows, because each
|
|
12 frame has its own set of windows. Each window belongs to one and only
|
|
13 one frame.
|
|
14
|
|
15 @menu
|
|
16 * Basic Window:: Introduction to Emacs windows.
|
|
17 * Split Window:: New windows are made by splitting existing windows.
|
|
18 * Other Window:: Moving to another window or doing something to it.
|
|
19 * Pop Up Window:: Finding a file or buffer in another window.
|
|
20 * Force Same Window:: Forcing certain buffers to appear in the selected
|
|
21 window rather than in another window.
|
|
22 * Change Window:: Deleting windows and changing their sizes.
|
|
23 @end menu
|
|
24
|
|
25 @node Basic Window
|
|
26 @section Concepts of Emacs Windows
|
|
27
|
|
28 Each Emacs window displays one Emacs buffer at any time. A single
|
|
29 buffer may appear in more than one window; if it does, any changes in
|
|
30 its text are displayed in all the windows where it appears. But the
|
|
31 windows showing the same buffer can show different parts of it, because
|
|
32 each window has its own value of point.
|
|
33
|
|
34 @cindex selected window
|
|
35 At any time, one of the windows is the @dfn{selected window}; the
|
|
36 buffer this window is displaying is the current buffer. The terminal's
|
|
37 cursor shows the location of point in this window. Each other window
|
|
38 has a location of point as well, but since the terminal has only one
|
|
39 cursor there is no way to show where those locations are. When multiple
|
|
40 frames are visible in X Windows, each frame has a cursor which appears
|
|
41 in the frame's selected window. The cursor in the selected frame is
|
|
42 solid; the cursor in other frames is a hollow box.
|
|
43
|
|
44 Commands to move point affect the value of point for the selected Emacs
|
|
45 window only. They do not change the value of point in any other Emacs
|
|
46 window, even one showing the same buffer. The same is true for commands
|
|
47 such as @kbd{C-x b} to change the selected buffer in the selected window;
|
|
48 they do not affect other windows at all. However, there are other commands
|
|
49 such as @kbd{C-x 4 b} that select a different window and switch buffers in
|
|
50 it. Also, all commands that display information in a window, including
|
|
51 (for example) @kbd{C-h f} (@code{describe-function}) and @kbd{C-x C-b}
|
|
52 (@code{list-buffers}), work by switching buffers in a nonselected window
|
|
53 without affecting the selected window.
|
|
54
|
|
55 When multiple windows show the same buffer, they can have different
|
|
56 regions, because they can have different values of point. However,
|
|
57 they all have the same value for the mark, because each buffer has
|
|
58 only one mark position.
|
|
59
|
|
60 Each window has its own mode line, which displays the buffer name,
|
|
61 modification status and major and minor modes of the buffer that is
|
|
62 displayed in the window. @xref{Mode Line}, for full details on the mode
|
|
63 line.
|
|
64
|
|
65 @iftex
|
|
66 @break
|
|
67 @end iftex
|
|
68
|
|
69 @node Split Window
|
|
70 @section Splitting Windows
|
|
71
|
|
72 @table @kbd
|
|
73 @item C-x 2
|
|
74 Split the selected window into two windows, one above the other
|
|
75 (@code{split-window-vertically}).
|
|
76 @item C-x 3
|
|
77 Split the selected window into two windows positioned side by side
|
|
78 (@code{split-window-horizontally}).
|
|
79 @item C-Mouse-2
|
|
80 In the mode line or scroll bar of a window, split that window.
|
|
81 @end table
|
|
82
|
|
83 @kindex C-x 2
|
|
84 @findex split-window-vertically
|
|
85 The command @kbd{C-x 2} (@code{split-window-vertically}) breaks the
|
|
86 selected window into two windows, one above the other. Both windows start
|
|
87 out displaying the same buffer, with the same value of point. By default
|
|
88 the two windows each get half the height of the window that was split; a
|
|
89 numeric argument specifies how many lines to give to the top window.
|
|
90
|
|
91 @kindex C-x 3
|
|
92 @findex split-window-horizontally
|
|
93 @kbd{C-x 3} (@code{split-window-horizontally}) breaks the selected
|
|
94 window into two side-by-side windows. A numeric argument specifies how
|
|
95 many columns to give the one on the left. A line of vertical bars
|
|
96 separates the two windows. Windows that are not the full width of the
|
|
97 screen have mode lines, but they are truncated. On terminals where
|
|
98 Emacs does not support highlighting, truncated mode lines sometimes do
|
|
99 not appear in inverse video.
|
|
100
|
|
101 @kindex C-Mouse-2 @r{(scroll bar)}
|
|
102 You can split a window horizontally or vertically by clicking
|
|
103 @kbd{C-Mouse-2} in the mode line or the scroll bar. The line of
|
|
104 splitting goes through the place where you click: if you click on the
|
|
105 mode line, the new scroll bar goes above the spot; if you click in the
|
|
106 scroll bar, the mode line of the split window is side by side with your
|
|
107 click.
|
|
108
|
|
109 @vindex truncate-partial-width-windows
|
|
110 When a window is less than the full width, text lines too long to fit are
|
|
111 frequent. Continuing all those lines might be confusing. The variable
|
|
112 @code{truncate-partial-width-windows} can be set non-@code{nil} to force
|
|
113 truncation in all windows less than the full width of the screen,
|
|
114 independent of the buffer being displayed and its value for
|
|
115 @code{truncate-lines}. @xref{Continuation Lines}.@refill
|
|
116
|
|
117 Horizontal scrolling is often used in side-by-side windows.
|
|
118 @xref{Display}.
|
|
119
|
|
120 @vindex split-window-keep-point
|
|
121 If @code{split-window-keep-point} is non-@code{nil}, the default, both
|
|
122 of the windows resulting from @kbd{C-x 2} inherit the value of point
|
|
123 from the window that was split. This means that scrolling is
|
|
124 inevitable. If this variable is @code{nil}, then @kbd{C-x 2} tries to
|
|
125 avoid shifting any text the screen, by putting point in each window at a
|
|
126 position already visible in the window. It also selects whichever
|
|
127 window contain the screen line that the cursor was previously on. Some
|
|
128 users prefer the latter mode on slow terminals.
|
|
129
|
|
130 @node Other Window
|
|
131 @section Using Other Windows
|
|
132
|
|
133 @table @kbd
|
|
134 @item C-x o
|
|
135 Select another window (@code{other-window}). That is @kbd{o}, not zero.
|
|
136 @item C-M-v
|
|
137 Scroll the next window (@code{scroll-other-window}).
|
|
138 @item M-x compare-windows
|
|
139 Find next place where the text in the selected window does not match
|
|
140 the text in the next window.
|
|
141 @item Mouse-1
|
|
142 @kbd{Mouse-1}, in a window's mode line, selects that window
|
|
143 but does not move point in it (@code{mouse-select-window}).
|
|
144 @end table
|
|
145
|
|
146 @kindex C-x o
|
|
147 @findex other-window
|
|
148 To select a different window, click with @kbd{Mouse-1} on its mode
|
|
149 line. With the keyboard, you can switch windows by typing @kbd{C-x o}
|
|
150 (@code{other-window}). That is an @kbd{o}, for `other', not a zero.
|
|
151 When there are more than two windows, this command moves through all the
|
|
152 windows in a cyclic order, generally top to bottom and left to right.
|
|
153 After the rightmost and bottommost window, it goes back to the one at
|
|
154 the upper left corner. A numeric argument means to move several steps
|
|
155 in the cyclic order of windows. A negative argument moves around the
|
|
156 cycle in the opposite order. When the minibuffer is active, the
|
|
157 minibuffer is the last window in the cycle; you can switch from the
|
|
158 minibuffer window to one of the other windows, and later switch back and
|
|
159 finish supplying the minibuffer argument that is requested.
|
|
160 @xref{Minibuffer Edit}.
|
|
161
|
|
162 @kindex C-M-v
|
|
163 @findex scroll-other-window
|
|
164 The usual scrolling commands (@pxref{Display}) apply to the selected
|
|
165 window only, but there is one command to scroll the next window.
|
|
166 @kbd{C-M-v} (@code{scroll-other-window}) scrolls the window that
|
|
167 @kbd{C-x o} would select. It takes arguments, positive and negative,
|
|
168 like @kbd{C-v}. (In the minibuffer, @kbd{C-M-v} scrolls the window
|
|
169 that contains the minibuffer help display, if any, rather than the
|
|
170 next window in the standard cyclic order.)
|
|
171
|
|
172 The command @kbd{M-x compare-windows} lets you compare two files or
|
|
173 buffers visible in two windows, by moving through them to the next
|
|
174 mismatch. @xref{Comparing Files}, for details.
|
|
175
|
|
176 @node Pop Up Window
|
|
177 @section Displaying in Another Window
|
|
178
|
|
179 @cindex selecting buffers in other windows
|
|
180 @kindex C-x 4
|
|
181 @kbd{C-x 4} is a prefix key for commands that select another window
|
|
182 (splitting the window if there is only one) and select a buffer in that
|
|
183 window. Different @kbd{C-x 4} commands have different ways of finding the
|
|
184 buffer to select.
|
|
185
|
|
186 @table @kbd
|
|
187 @item C-x 4 b @var{bufname} @key{RET}
|
|
188 Select buffer @var{bufname} in another window. This runs
|
|
189 @code{switch-to-buffer-other-window}.
|
|
190 @item C-x 4 C-o @var{bufname} @key{RET}
|
|
191 Display buffer @var{bufname} in another window, but
|
|
192 don't select that buffer or that window. This runs
|
|
193 @code{display-buffer}.
|
|
194 @item C-x 4 f @var{filename} @key{RET}
|
|
195 Visit file @var{filename} and select its buffer in another window. This
|
|
196 runs @code{find-file-other-window}. @xref{Visiting}.
|
|
197 @item C-x 4 d @var{directory} @key{RET}
|
|
198 Select a Dired buffer for directory @var{directory} in another window.
|
|
199 This runs @code{dired-other-window}. @xref{Dired}.
|
|
200 @item C-x 4 m
|
|
201 Start composing a mail message in another window. This runs
|
|
202 @code{mail-other-window}; its same-window analogue is @kbd{C-x m}
|
|
203 (@pxref{Sending Mail}).
|
|
204 @item C-x 4 .
|
|
205 Find a tag in the current tags table, in another window. This runs
|
|
206 @code{find-tag-other-window}, the multiple-window variant of @kbd{M-.}
|
|
207 (@pxref{Tags}).
|
|
208 @item C-x 4 r @var{filename} @key{RET}
|
|
209 Visit file @var{filename} read-only, and select its buffer in another
|
|
210 window. This runs @code{find-file-read-only-other-window}.
|
|
211 @xref{Visiting}.
|
|
212 @end table
|
|
213
|
|
214 @node Force Same Window
|
|
215 @section Forcing Display in the Same Window
|
|
216
|
|
217 Certain Emacs commands switch to a specific buffer with special
|
|
218 contents. For example, @kbd{M-x shell} switches to a buffer named
|
|
219 @samp{*Shell*}. By convention, all these commands are written to pop up
|
|
220 the buffer in a separate window. But you can specify that certain of
|
|
221 these buffers should appear in the selected window.
|
|
222
|
|
223 @vindex same-window-buffer-names
|
|
224 If you add a buffer name to the list @code{same-window-buffer-names},
|
|
225 the effect is that such commands display that particular buffer by
|
|
226 switching to it in the selected window. For example, if you add the
|
|
227 element @code{"*grep*"} to the list, the @code{grep} command will
|
|
228 display its output buffer in the selected window.
|
|
229
|
|
230 The default value of @code{same-window-buffer-names} is not
|
|
231 @code{nil}: it specifies buffer names @samp{*info*}, @samp{*mail*} and
|
|
232 @samp{*shell*} (as well as others used by more obscure Emacs packages).
|
|
233 This is why @kbd{M-x shell} normally switches to the @samp{*shell*}
|
|
234 buffer in the selected window. If you delete this element from the
|
|
235 value of @code{same-window-buffer-names}, the behavior of @kbd{M-x
|
|
236 shell} will change---it will pop up the buffer in another window
|
|
237 instead.
|
|
238
|
|
239 @vindex same-window-regexps
|
|
240 You can specify these buffers more generally with the variable
|
|
241 @code{same-window-regexps}. Set it to a list of regular expressions;
|
|
242 then any buffer whose name matches one of those regular expressions is
|
|
243 displayed by switching to it in the selected window. (Once again, this
|
|
244 applies only to buffers that normally get displayed for you in a
|
|
245 separate window.) The default value of this variable specifies Telnet
|
|
246 and rlogin buffers.
|
|
247
|
|
248 An analogous feature lets you specify buffers which should be
|
|
249 displayed in their own individual frames. @xref{Special Buffer Frames}.
|
|
250
|
|
251 @node Change Window
|
|
252 @section Deleting and Rearranging Windows
|
|
253
|
|
254 @table @kbd
|
|
255 @item C-x 0
|
|
256 Delete the selected window (@code{delete-window}). The last character
|
|
257 in this key sequence is a zero.
|
|
258 @item C-x 1
|
|
259 Delete all windows in the selected frame except the selected window
|
|
260 (@code{delete-other-windows}).
|
|
261 @item C-x 4 0
|
|
262 Delete the selected window and kill the buffer that was showing in it
|
|
263 (@code{kill-buffer-and-window}). The last character in this key
|
|
264 sequence is a zero.
|
|
265 @item C-x ^
|
|
266 Make selected window taller (@code{enlarge-window}).
|
|
267 @item C-x @}
|
|
268 Make selected window wider (@code{enlarge-window-horizontally}).
|
|
269 @item C-x @{
|
|
270 Make selected window narrower (@code{shrink-window-horizontally}).
|
|
271 @item C-x -
|
|
272 Shrink this window if its buffer doesn't need so many lines
|
|
273 (@code{shrink-window-if-larger-than-buffer}).
|
|
274 @item C-x +
|
|
275 Make all windows the same height (@code{balance-windows}).
|
|
276 @item Drag-Mouse-1
|
|
277 Dragging a window's mode line up or down with @kbd{Mouse-1} changes
|
|
278 window heights.
|
|
279 @item Mouse-2
|
|
280 @kbd{Mouse-2} in a window's mode line deletes all other windows in the frame
|
|
281 (@code{mouse-delete-other-windows}).
|
|
282 @item Mouse-3
|
|
283 @kbd{Mouse-3} in a window's mode line deletes that window
|
|
284 (@code{mouse-delete-window}).
|
|
285 @end table
|
|
286
|
|
287 @kindex C-x 0
|
|
288 @findex delete-window
|
|
289 To delete a window, type @kbd{C-x 0} (@code{delete-window}). (That is
|
|
290 a zero.) The space occupied by the deleted window is given to an
|
|
291 adjacent window (but not the minibuffer window, even if that is active
|
|
292 at the time). Once a window is deleted, its attributes are forgotten;
|
|
293 only restoring a window configuration can bring it back. Deleting the
|
|
294 window has no effect on the buffer it used to display; the buffer
|
|
295 continues to exist, and you can select it in any window with @kbd{C-x
|
|
296 b}.
|
|
297
|
|
298 @findex kill-buffer-and-window
|
|
299 @kindex C-x 4 0
|
|
300 @kbd{C-x 4 0} (@code{kill-buffer-and-window}) is a stronger command
|
|
301 than @kbd{C-x 0}; it kills the current buffer and then deletes the
|
|
302 selected window.
|
|
303
|
|
304 @kindex C-x 1
|
|
305 @findex delete-other-windows
|
|
306 @kbd{C-x 1} (@code{delete-other-windows}) is more powerful in a
|
|
307 different way; it deletes all the windows except the selected one (and
|
|
308 the minibuffer); the selected window expands to use the whole frame
|
|
309 except for the echo area.
|
|
310
|
|
311 You can also delete a window by clicking on its mode line with
|
|
312 @kbd{Mouse-2}, and delete all the windows in a frame except one window
|
|
313 by clicking on that window's mode line with @kbd{Mouse-3}.
|
|
314
|
|
315 The easiest way to adjust window heights is with a mouse. If you
|
|
316 press @kbd{Mouse-1} on a mode line, you can drag that mode line up or
|
|
317 down, changing the heights of the windows above and below it.
|
|
318
|
|
319 @kindex C-x ^
|
|
320 @findex enlarge-window
|
|
321 @kindex C-x @}
|
|
322 @findex enlarge-window-horizontally
|
|
323 @vindex window-min-height
|
|
324 @vindex window-min-width
|
|
325 To readjust the division of space among vertically adjacent windows,
|
|
326 use @kbd{C-x ^} (@code{enlarge-window}). It makes the currently
|
|
327 selected window get one line bigger, or as many lines as is specified
|
|
328 with a numeric argument. With a negative argument, it makes the
|
|
329 selected window smaller. @kbd{C-x @}}
|
|
330 (@code{enlarge-window-horizontally}) makes the selected window wider by
|
|
331 the specified number of columns. @kbd{C-x @{}
|
|
332 (@code{shrink-window-horizontally}) makes the selected window narrower
|
|
333 by the specified number of columns.
|
|
334
|
|
335 When you make a window bigger, the space comes from one of its
|
|
336 neighbors. If this makes any window too small, it is deleted and its
|
|
337 space is given to an adjacent window. The minimum size is specified by
|
|
338 the variables @code{window-min-height} and @code{window-min-width}.
|
|
339
|
|
340 @kindex C-x -
|
|
341 @findex shrink-window-if-larger-than-buffer
|
|
342 The command @kbd{C-x -} (@code{shrink-window-if-larger-than-buffer})
|
|
343 reduces the height of the selected window, if it is taller than
|
|
344 necessary to show the whole text of the buffer it is displaying. It
|
|
345 gives the extra lines to other windows in the frame.
|
|
346
|
|
347 @kindex C-x +
|
|
348 @findex balance-windows
|
|
349 You can also use @kbd{C-x +} (@code{balance-windows}) to even out the
|
|
350 heights of all the windows in the selected frame.
|
|
351
|
|
352 @xref{Minibuffer Edit}, for information about the Resize-Minibuffer
|
|
353 mode, which automatically changes the size of the minibuffer window to
|
|
354 fit the text in the minibuffer.
|