Mercurial > emacs
annotate man/windows.texi @ 35879:1b871d9c3be4
Docstring fixes.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 04 Feb 2001 20:57:37 +0000 |
parents | 94d46968a93f |
children | c869b148aa3f |
rev | line source |
---|---|
25829 | 1 @c This is part of the Emacs manual. |
30875 | 2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 2000 Free Software Foundation, Inc. |
25829 | 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. | |
28551 | 23 * Window Convenience:: Convenience functions for window handling. |
25829 | 24 @end menu |
25 | |
26 @node Basic Window | |
27 @section Concepts of Emacs Windows | |
28 | |
29 Each Emacs window displays one Emacs buffer at any time. A single | |
30 buffer may appear in more than one window; if it does, any changes in | |
31 its text are displayed in all the windows where it appears. But the | |
32 windows showing the same buffer can show different parts of it, because | |
33 each window has its own value of point. | |
34 | |
35 @cindex selected window | |
36 At any time, one of the windows is the @dfn{selected window}; the | |
37 buffer this window is displaying is the current buffer. The terminal's | |
38 cursor shows the location of point in this window. Each other window | |
39 has a location of point as well, but since the terminal has only one | |
40 cursor there is no way to show where those locations are. When multiple | |
35188
94d46968a93f
Don't say "X Windows". From Colin Walters <walters@cis.ohio-state.edu>.
Eli Zaretskii <eliz@gnu.org>
parents:
34565
diff
changeset
|
41 frames are visible in X, each frame has a cursor which appears in the |
94d46968a93f
Don't say "X Windows". From Colin Walters <walters@cis.ohio-state.edu>.
Eli Zaretskii <eliz@gnu.org>
parents:
34565
diff
changeset
|
42 frame's selected window. The cursor in the selected frame is solid; the |
94d46968a93f
Don't say "X Windows". From Colin Walters <walters@cis.ohio-state.edu>.
Eli Zaretskii <eliz@gnu.org>
parents:
34565
diff
changeset
|
43 cursor in other frames is a hollow box. |
25829 | 44 |
45 Commands to move point affect the value of point for the selected Emacs | |
46 window only. They do not change the value of point in any other Emacs | |
47 window, even one showing the same buffer. The same is true for commands | |
48 such as @kbd{C-x b} to change the selected buffer in the selected window; | |
49 they do not affect other windows at all. However, there are other commands | |
50 such as @kbd{C-x 4 b} that select a different window and switch buffers in | |
51 it. Also, all commands that display information in a window, including | |
52 (for example) @kbd{C-h f} (@code{describe-function}) and @kbd{C-x C-b} | |
53 (@code{list-buffers}), work by switching buffers in a nonselected window | |
54 without affecting the selected window. | |
55 | |
56 When multiple windows show the same buffer, they can have different | |
57 regions, because they can have different values of point. However, | |
58 they all have the same value for the mark, because each buffer has | |
59 only one mark position. | |
60 | |
61 Each window has its own mode line, which displays the buffer name, | |
62 modification status and major and minor modes of the buffer that is | |
63 displayed in the window. @xref{Mode Line}, for full details on the mode | |
64 line. | |
65 | |
66 @iftex | |
67 @break | |
68 @end iftex | |
69 | |
70 @node Split Window | |
71 @section Splitting Windows | |
72 | |
73 @table @kbd | |
74 @item C-x 2 | |
75 Split the selected window into two windows, one above the other | |
76 (@code{split-window-vertically}). | |
77 @item C-x 3 | |
78 Split the selected window into two windows positioned side by side | |
79 (@code{split-window-horizontally}). | |
80 @item C-Mouse-2 | |
81 In the mode line or scroll bar of a window, split that window. | |
82 @end table | |
83 | |
84 @kindex C-x 2 | |
85 @findex split-window-vertically | |
86 The command @kbd{C-x 2} (@code{split-window-vertically}) breaks the | |
87 selected window into two windows, one above the other. Both windows start | |
88 out displaying the same buffer, with the same value of point. By default | |
89 the two windows each get half the height of the window that was split; a | |
90 numeric argument specifies how many lines to give to the top window. | |
91 | |
92 @kindex C-x 3 | |
93 @findex split-window-horizontally | |
94 @kbd{C-x 3} (@code{split-window-horizontally}) breaks the selected | |
95 window into two side-by-side windows. A numeric argument specifies how | |
96 many columns to give the one on the left. A line of vertical bars | |
97 separates the two windows. Windows that are not the full width of the | |
98 screen have mode lines, but they are truncated. On terminals where | |
99 Emacs does not support highlighting, truncated mode lines sometimes do | |
100 not appear in inverse video. | |
101 | |
102 @kindex C-Mouse-2 @r{(scroll bar)} | |
103 You can split a window horizontally or vertically by clicking | |
104 @kbd{C-Mouse-2} in the mode line or the scroll bar. The line of | |
105 splitting goes through the place where you click: if you click on the | |
106 mode line, the new scroll bar goes above the spot; if you click in the | |
107 scroll bar, the mode line of the split window is side by side with your | |
108 click. | |
109 | |
110 @vindex truncate-partial-width-windows | |
111 When a window is less than the full width, text lines too long to fit are | |
112 frequent. Continuing all those lines might be confusing. The variable | |
113 @code{truncate-partial-width-windows} can be set non-@code{nil} to force | |
114 truncation in all windows less than the full width of the screen, | |
115 independent of the buffer being displayed and its value for | |
116 @code{truncate-lines}. @xref{Continuation Lines}.@refill | |
117 | |
118 Horizontal scrolling is often used in side-by-side windows. | |
119 @xref{Display}. | |
120 | |
121 @vindex split-window-keep-point | |
122 If @code{split-window-keep-point} is non-@code{nil}, the default, both | |
123 of the windows resulting from @kbd{C-x 2} inherit the value of point | |
124 from the window that was split. This means that scrolling is | |
125 inevitable. If this variable is @code{nil}, then @kbd{C-x 2} tries to | |
126 avoid shifting any text the screen, by putting point in each window at a | |
127 position already visible in the window. It also selects whichever | |
128 window contain the screen line that the cursor was previously on. Some | |
129 users prefer the latter mode on slow terminals. | |
130 | |
131 @node Other Window | |
132 @section Using Other Windows | |
133 | |
134 @table @kbd | |
135 @item C-x o | |
136 Select another window (@code{other-window}). That is @kbd{o}, not zero. | |
137 @item C-M-v | |
138 Scroll the next window (@code{scroll-other-window}). | |
139 @item M-x compare-windows | |
140 Find next place where the text in the selected window does not match | |
141 the text in the next window. | |
142 @item Mouse-1 | |
143 @kbd{Mouse-1}, in a window's mode line, selects that window | |
144 but does not move point in it (@code{mouse-select-window}). | |
145 @end table | |
146 | |
147 @kindex C-x o | |
148 @findex other-window | |
149 To select a different window, click with @kbd{Mouse-1} on its mode | |
150 line. With the keyboard, you can switch windows by typing @kbd{C-x o} | |
151 (@code{other-window}). That is an @kbd{o}, for `other', not a zero. | |
152 When there are more than two windows, this command moves through all the | |
153 windows in a cyclic order, generally top to bottom and left to right. | |
154 After the rightmost and bottommost window, it goes back to the one at | |
155 the upper left corner. A numeric argument means to move several steps | |
156 in the cyclic order of windows. A negative argument moves around the | |
157 cycle in the opposite order. When the minibuffer is active, the | |
158 minibuffer is the last window in the cycle; you can switch from the | |
159 minibuffer window to one of the other windows, and later switch back and | |
160 finish supplying the minibuffer argument that is requested. | |
161 @xref{Minibuffer Edit}. | |
162 | |
163 @kindex C-M-v | |
164 @findex scroll-other-window | |
165 The usual scrolling commands (@pxref{Display}) apply to the selected | |
166 window only, but there is one command to scroll the next window. | |
167 @kbd{C-M-v} (@code{scroll-other-window}) scrolls the window that | |
168 @kbd{C-x o} would select. It takes arguments, positive and negative, | |
169 like @kbd{C-v}. (In the minibuffer, @kbd{C-M-v} scrolls the window | |
170 that contains the minibuffer help display, if any, rather than the | |
171 next window in the standard cyclic order.) | |
172 | |
173 The command @kbd{M-x compare-windows} lets you compare two files or | |
174 buffers visible in two windows, by moving through them to the next | |
175 mismatch. @xref{Comparing Files}, for details. | |
176 | |
177 @node Pop Up Window | |
178 @section Displaying in Another Window | |
179 | |
180 @cindex selecting buffers in other windows | |
181 @kindex C-x 4 | |
182 @kbd{C-x 4} is a prefix key for commands that select another window | |
183 (splitting the window if there is only one) and select a buffer in that | |
184 window. Different @kbd{C-x 4} commands have different ways of finding the | |
185 buffer to select. | |
186 | |
187 @table @kbd | |
188 @item C-x 4 b @var{bufname} @key{RET} | |
189 Select buffer @var{bufname} in another window. This runs | |
190 @code{switch-to-buffer-other-window}. | |
191 @item C-x 4 C-o @var{bufname} @key{RET} | |
192 Display buffer @var{bufname} in another window, but | |
193 don't select that buffer or that window. This runs | |
194 @code{display-buffer}. | |
195 @item C-x 4 f @var{filename} @key{RET} | |
196 Visit file @var{filename} and select its buffer in another window. This | |
197 runs @code{find-file-other-window}. @xref{Visiting}. | |
198 @item C-x 4 d @var{directory} @key{RET} | |
199 Select a Dired buffer for directory @var{directory} in another window. | |
200 This runs @code{dired-other-window}. @xref{Dired}. | |
201 @item C-x 4 m | |
202 Start composing a mail message in another window. This runs | |
203 @code{mail-other-window}; its same-window analogue is @kbd{C-x m} | |
204 (@pxref{Sending Mail}). | |
205 @item C-x 4 . | |
206 Find a tag in the current tags table, in another window. This runs | |
207 @code{find-tag-other-window}, the multiple-window variant of @kbd{M-.} | |
208 (@pxref{Tags}). | |
209 @item C-x 4 r @var{filename} @key{RET} | |
210 Visit file @var{filename} read-only, and select its buffer in another | |
211 window. This runs @code{find-file-read-only-other-window}. | |
212 @xref{Visiting}. | |
213 @end table | |
214 | |
215 @node Force Same Window | |
216 @section Forcing Display in the Same Window | |
217 | |
218 Certain Emacs commands switch to a specific buffer with special | |
219 contents. For example, @kbd{M-x shell} switches to a buffer named | |
220 @samp{*Shell*}. By convention, all these commands are written to pop up | |
221 the buffer in a separate window. But you can specify that certain of | |
222 these buffers should appear in the selected window. | |
223 | |
224 @vindex same-window-buffer-names | |
225 If you add a buffer name to the list @code{same-window-buffer-names}, | |
226 the effect is that such commands display that particular buffer by | |
227 switching to it in the selected window. For example, if you add the | |
228 element @code{"*grep*"} to the list, the @code{grep} command will | |
229 display its output buffer in the selected window. | |
230 | |
231 The default value of @code{same-window-buffer-names} is not | |
232 @code{nil}: it specifies buffer names @samp{*info*}, @samp{*mail*} and | |
233 @samp{*shell*} (as well as others used by more obscure Emacs packages). | |
234 This is why @kbd{M-x shell} normally switches to the @samp{*shell*} | |
235 buffer in the selected window. If you delete this element from the | |
236 value of @code{same-window-buffer-names}, the behavior of @kbd{M-x | |
237 shell} will change---it will pop up the buffer in another window | |
238 instead. | |
239 | |
240 @vindex same-window-regexps | |
241 You can specify these buffers more generally with the variable | |
242 @code{same-window-regexps}. Set it to a list of regular expressions; | |
243 then any buffer whose name matches one of those regular expressions is | |
244 displayed by switching to it in the selected window. (Once again, this | |
245 applies only to buffers that normally get displayed for you in a | |
246 separate window.) The default value of this variable specifies Telnet | |
247 and rlogin buffers. | |
248 | |
249 An analogous feature lets you specify buffers which should be | |
250 displayed in their own individual frames. @xref{Special Buffer Frames}. | |
251 | |
252 @node Change Window | |
253 @section Deleting and Rearranging Windows | |
254 | |
255 @table @kbd | |
256 @item C-x 0 | |
257 Delete the selected window (@code{delete-window}). The last character | |
258 in this key sequence is a zero. | |
259 @item C-x 1 | |
260 Delete all windows in the selected frame except the selected window | |
261 (@code{delete-other-windows}). | |
262 @item C-x 4 0 | |
263 Delete the selected window and kill the buffer that was showing in it | |
264 (@code{kill-buffer-and-window}). The last character in this key | |
265 sequence is a zero. | |
266 @item C-x ^ | |
267 Make selected window taller (@code{enlarge-window}). | |
268 @item C-x @} | |
269 Make selected window wider (@code{enlarge-window-horizontally}). | |
270 @item C-x @{ | |
271 Make selected window narrower (@code{shrink-window-horizontally}). | |
272 @item C-x - | |
273 Shrink this window if its buffer doesn't need so many lines | |
274 (@code{shrink-window-if-larger-than-buffer}). | |
275 @item C-x + | |
276 Make all windows the same height (@code{balance-windows}). | |
277 @item Drag-Mouse-1 | |
278 Dragging a window's mode line up or down with @kbd{Mouse-1} changes | |
279 window heights. | |
280 @item Mouse-2 | |
281 @kbd{Mouse-2} in a window's mode line deletes all other windows in the frame | |
282 (@code{mouse-delete-other-windows}). | |
283 @item Mouse-3 | |
284 @kbd{Mouse-3} in a window's mode line deletes that window | |
285 (@code{mouse-delete-window}). | |
286 @end table | |
287 | |
288 @kindex C-x 0 | |
289 @findex delete-window | |
290 To delete a window, type @kbd{C-x 0} (@code{delete-window}). (That is | |
291 a zero.) The space occupied by the deleted window is given to an | |
292 adjacent window (but not the minibuffer window, even if that is active | |
293 at the time). Once a window is deleted, its attributes are forgotten; | |
294 only restoring a window configuration can bring it back. Deleting the | |
295 window has no effect on the buffer it used to display; the buffer | |
296 continues to exist, and you can select it in any window with @kbd{C-x | |
297 b}. | |
298 | |
299 @findex kill-buffer-and-window | |
300 @kindex C-x 4 0 | |
301 @kbd{C-x 4 0} (@code{kill-buffer-and-window}) is a stronger command | |
302 than @kbd{C-x 0}; it kills the current buffer and then deletes the | |
303 selected window. | |
304 | |
305 @kindex C-x 1 | |
306 @findex delete-other-windows | |
307 @kbd{C-x 1} (@code{delete-other-windows}) is more powerful in a | |
308 different way; it deletes all the windows except the selected one (and | |
309 the minibuffer); the selected window expands to use the whole frame | |
310 except for the echo area. | |
311 | |
312 You can also delete a window by clicking on its mode line with | |
313 @kbd{Mouse-2}, and delete all the windows in a frame except one window | |
314 by clicking on that window's mode line with @kbd{Mouse-3}. | |
315 | |
316 The easiest way to adjust window heights is with a mouse. If you | |
317 press @kbd{Mouse-1} on a mode line, you can drag that mode line up or | |
318 down, changing the heights of the windows above and below it. | |
319 | |
320 @kindex C-x ^ | |
321 @findex enlarge-window | |
322 @kindex C-x @} | |
323 @findex enlarge-window-horizontally | |
324 @vindex window-min-height | |
325 @vindex window-min-width | |
326 To readjust the division of space among vertically adjacent windows, | |
327 use @kbd{C-x ^} (@code{enlarge-window}). It makes the currently | |
328 selected window get one line bigger, or as many lines as is specified | |
329 with a numeric argument. With a negative argument, it makes the | |
330 selected window smaller. @kbd{C-x @}} | |
331 (@code{enlarge-window-horizontally}) makes the selected window wider by | |
332 the specified number of columns. @kbd{C-x @{} | |
333 (@code{shrink-window-horizontally}) makes the selected window narrower | |
334 by the specified number of columns. | |
335 | |
336 When you make a window bigger, the space comes from one of its | |
337 neighbors. If this makes any window too small, it is deleted and its | |
338 space is given to an adjacent window. The minimum size is specified by | |
339 the variables @code{window-min-height} and @code{window-min-width}. | |
340 | |
341 @kindex C-x - | |
342 @findex shrink-window-if-larger-than-buffer | |
343 The command @kbd{C-x -} (@code{shrink-window-if-larger-than-buffer}) | |
344 reduces the height of the selected window, if it is taller than | |
345 necessary to show the whole text of the buffer it is displaying. It | |
346 gives the extra lines to other windows in the frame. | |
347 | |
348 @kindex C-x + | |
349 @findex balance-windows | |
350 You can also use @kbd{C-x +} (@code{balance-windows}) to even out the | |
351 heights of all the windows in the selected frame. | |
352 | |
28551 | 353 @node Window Convenience |
354 @section Window Handling Convenience Features and Customization | |
355 | |
356 @findex winner-mode | |
30875 | 357 @cindex Winner mode |
358 @cindex mode, Winner | |
28551 | 359 @cindex undoing window configuration changes |
360 @cindex window configuration changes, undoing | |
361 @kbd{M-x winner-mode} provides a global minor mode that records the | |
362 changes in the window configuration (i.e. how the frames are partitioned | |
363 into windows) so that the changes can be `undone' using the command | |
364 @kbd{M-x winner-undo}, bound to @kbd{C-x left} by default. If you | |
365 change your mind (while undoing), you can use @kbd{M-x winner-redo} | |
366 (@kbd{C-x right}). You can also turn on Winner mode by customizing | |
367 @code{winner-mode}. | |
368 | |
369 @vindex scroll-all-mode | |
370 @cindex scrolling windows together | |
30875 | 371 @cindex Scroll-all mode |
372 @cindex mode, Scroll-all | |
28551 | 373 @kbd{M-x scroll-all-mode} provides commands to scroll all visible |
374 windows together as in CRiSP/Brief emulation (@pxref{Emulation}). You | |
375 can also turn it on by customizing @code{scroll-all-mode}. The commands | |
376 provided are @kbd{M-x scroll-all-scroll-down-all}, @kbd{M-x | |
377 scroll-all-page-down-all} and their `up' equivalents. You would | |
378 probably want to bind these to appropriate keys. | |
379 | |
380 @cindex Windmove package | |
381 @cindex directional window selection | |
30875 | 382 @findex windmove-right |
383 @findex windmove-default-keybindings | |
384 There are commands to move directionally between neighbouring windows in | |
385 a frame. @kbd{M-x windmove-right} selects the window immediately to the | |
386 right of the currently-selected one and similarly for the `left', `up' | |
387 and `down' counterparts. @kbd{M-x windmove-default-keybindings} binds | |
388 these commands to @kbd{S-right} etc. (These bindings will only work if | |
389 your terminal supports shifted arrow keys.) | |
28551 | 390 |
391 @cindex Follow mode | |
30875 | 392 @cindex mode, Follow |
393 @findex follow-mode | |
28551 | 394 @cindex windows, synchronizing |
395 @cindex synchronizing windows | |
396 Follow minor mode (@kbd{M-x follow-mode}) synchronizes several windows | |
397 on the same buffer so that they always display adjacent sections of that | |
398 buffer. Also if point moves outside a window, another window displaying | |
399 that point is selected if possible, so that you can move between windows | |
400 with normal movement commands. You can use this facility, for instance, | |
401 to operate effectively with double the number of lines of a file visible | |
402 in a given screen height using side-by-side windows on the same buffer: | |
403 split the window with @kbd{C-x 3} and then use @kbd{M-x follow-mode} to | |
404 synchronize the windows. | |
34565
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
405 |
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
406 @cindex cursor in non-selected windows |
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
407 @vindex show-cursor-in-non-selected-windows |
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
408 @vindex cursor-in-non-selected-windows |
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
409 Normally, the cursor in non-selected windows is shown as a hollow box. |
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
410 If you want Emacs not to display the cursor in non-selected windows, |
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
411 customize the option @code{show-cursor-in-non-selected-windows}, or set |
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
412 the variable @code{cursor-in-non-selected-windows} to a non-@code{nil} |
5c6c44b995ef
Document show-cursor-in-non-selected-windows and
Eli Zaretskii <eliz@gnu.org>
parents:
30875
diff
changeset
|
413 value. |