Mercurial > emacs
annotate man/windows.texi @ 43290:3198ecb4e71f
Minor clarification.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 14 Feb 2002 01:38:49 +0000 |
parents | 3b40423b9355 |
children | 19cf9993da08 |
rev | line source |
---|---|
25829 | 1 @c This is part of the Emacs manual. |
39287 | 2 @c Copyright (C) 1985,86,87,93,94,95,97,2000,2001 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 | |
37986
e11682cc1516
selected buffer => current buffer.
Richard M. Stallman <rms@gnu.org>
parents:
37121
diff
changeset
|
48 such as @kbd{C-x b} to change the current buffer in the selected window; |
25829 | 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 | |
37121 | 104 @kbd{C-Mouse-2} in the mode line or the scroll bar. (This does not |
105 work in scroll bars implemented by X toolkits.) The line of splitting | |
106 goes through the place where you click: if you click on the mode line, | |
107 the new scroll bar goes above the spot; if you click in the scroll | |
108 bar, the mode line of the split window is side by side with your | |
25829 | 109 click. |
110 | |
111 @vindex truncate-partial-width-windows | |
112 When a window is less than the full width, text lines too long to fit are | |
113 frequent. Continuing all those lines might be confusing. The variable | |
114 @code{truncate-partial-width-windows} can be set non-@code{nil} to force | |
115 truncation in all windows less than the full width of the screen, | |
116 independent of the buffer being displayed and its value for | |
117 @code{truncate-lines}. @xref{Continuation Lines}.@refill | |
118 | |
119 Horizontal scrolling is often used in side-by-side windows. | |
120 @xref{Display}. | |
121 | |
122 @vindex split-window-keep-point | |
37121 | 123 If @code{split-window-keep-point} is non-@code{nil}, the default, |
124 both of the windows resulting from @kbd{C-x 2} inherit the value of | |
125 point from the window that was split. This means that scrolling is | |
25829 | 126 inevitable. If this variable is @code{nil}, then @kbd{C-x 2} tries to |
37121 | 127 avoid scrolling the text currently visible on the screen, by putting |
128 point in each window at a position already visible in the window. It | |
129 also selects whichever window contain the screen line that the cursor | |
130 was previously on. Some users prefer the latter mode on slow | |
131 terminals. | |
25829 | 132 |
133 @node Other Window | |
134 @section Using Other Windows | |
135 | |
136 @table @kbd | |
137 @item C-x o | |
138 Select another window (@code{other-window}). That is @kbd{o}, not zero. | |
139 @item C-M-v | |
140 Scroll the next window (@code{scroll-other-window}). | |
141 @item M-x compare-windows | |
142 Find next place where the text in the selected window does not match | |
143 the text in the next window. | |
144 @item Mouse-1 | |
145 @kbd{Mouse-1}, in a window's mode line, selects that window | |
146 but does not move point in it (@code{mouse-select-window}). | |
147 @end table | |
148 | |
149 @kindex C-x o | |
150 @findex other-window | |
151 To select a different window, click with @kbd{Mouse-1} on its mode | |
152 line. With the keyboard, you can switch windows by typing @kbd{C-x o} | |
36185 | 153 (@code{other-window}). That is an @kbd{o}, for ``other,'' not a zero. |
25829 | 154 When there are more than two windows, this command moves through all the |
155 windows in a cyclic order, generally top to bottom and left to right. | |
156 After the rightmost and bottommost window, it goes back to the one at | |
157 the upper left corner. A numeric argument means to move several steps | |
158 in the cyclic order of windows. A negative argument moves around the | |
159 cycle in the opposite order. When the minibuffer is active, the | |
160 minibuffer is the last window in the cycle; you can switch from the | |
161 minibuffer window to one of the other windows, and later switch back and | |
162 finish supplying the minibuffer argument that is requested. | |
163 @xref{Minibuffer Edit}. | |
164 | |
165 @kindex C-M-v | |
166 @findex scroll-other-window | |
167 The usual scrolling commands (@pxref{Display}) apply to the selected | |
168 window only, but there is one command to scroll the next window. | |
169 @kbd{C-M-v} (@code{scroll-other-window}) scrolls the window that | |
170 @kbd{C-x o} would select. It takes arguments, positive and negative, | |
171 like @kbd{C-v}. (In the minibuffer, @kbd{C-M-v} scrolls the window | |
172 that contains the minibuffer help display, if any, rather than the | |
173 next window in the standard cyclic order.) | |
174 | |
175 The command @kbd{M-x compare-windows} lets you compare two files or | |
176 buffers visible in two windows, by moving through them to the next | |
177 mismatch. @xref{Comparing Files}, for details. | |
178 | |
179 @node Pop Up Window | |
180 @section Displaying in Another Window | |
181 | |
182 @cindex selecting buffers in other windows | |
183 @kindex C-x 4 | |
184 @kbd{C-x 4} is a prefix key for commands that select another window | |
185 (splitting the window if there is only one) and select a buffer in that | |
186 window. Different @kbd{C-x 4} commands have different ways of finding the | |
187 buffer to select. | |
188 | |
189 @table @kbd | |
190 @item C-x 4 b @var{bufname} @key{RET} | |
191 Select buffer @var{bufname} in another window. This runs | |
192 @code{switch-to-buffer-other-window}. | |
193 @item C-x 4 C-o @var{bufname} @key{RET} | |
194 Display buffer @var{bufname} in another window, but | |
195 don't select that buffer or that window. This runs | |
196 @code{display-buffer}. | |
197 @item C-x 4 f @var{filename} @key{RET} | |
198 Visit file @var{filename} and select its buffer in another window. This | |
199 runs @code{find-file-other-window}. @xref{Visiting}. | |
200 @item C-x 4 d @var{directory} @key{RET} | |
201 Select a Dired buffer for directory @var{directory} in another window. | |
202 This runs @code{dired-other-window}. @xref{Dired}. | |
203 @item C-x 4 m | |
204 Start composing a mail message in another window. This runs | |
205 @code{mail-other-window}; its same-window analogue is @kbd{C-x m} | |
206 (@pxref{Sending Mail}). | |
207 @item C-x 4 . | |
208 Find a tag in the current tags table, in another window. This runs | |
209 @code{find-tag-other-window}, the multiple-window variant of @kbd{M-.} | |
210 (@pxref{Tags}). | |
211 @item C-x 4 r @var{filename} @key{RET} | |
212 Visit file @var{filename} read-only, and select its buffer in another | |
213 window. This runs @code{find-file-read-only-other-window}. | |
214 @xref{Visiting}. | |
215 @end table | |
216 | |
217 @node Force Same Window | |
218 @section Forcing Display in the Same Window | |
219 | |
220 Certain Emacs commands switch to a specific buffer with special | |
221 contents. For example, @kbd{M-x shell} switches to a buffer named | |
222 @samp{*Shell*}. By convention, all these commands are written to pop up | |
223 the buffer in a separate window. But you can specify that certain of | |
224 these buffers should appear in the selected window. | |
225 | |
226 @vindex same-window-buffer-names | |
227 If you add a buffer name to the list @code{same-window-buffer-names}, | |
228 the effect is that such commands display that particular buffer by | |
229 switching to it in the selected window. For example, if you add the | |
230 element @code{"*grep*"} to the list, the @code{grep} command will | |
231 display its output buffer in the selected window. | |
232 | |
233 The default value of @code{same-window-buffer-names} is not | |
234 @code{nil}: it specifies buffer names @samp{*info*}, @samp{*mail*} and | |
235 @samp{*shell*} (as well as others used by more obscure Emacs packages). | |
236 This is why @kbd{M-x shell} normally switches to the @samp{*shell*} | |
237 buffer in the selected window. If you delete this element from the | |
238 value of @code{same-window-buffer-names}, the behavior of @kbd{M-x | |
239 shell} will change---it will pop up the buffer in another window | |
240 instead. | |
241 | |
242 @vindex same-window-regexps | |
243 You can specify these buffers more generally with the variable | |
244 @code{same-window-regexps}. Set it to a list of regular expressions; | |
245 then any buffer whose name matches one of those regular expressions is | |
246 displayed by switching to it in the selected window. (Once again, this | |
247 applies only to buffers that normally get displayed for you in a | |
248 separate window.) The default value of this variable specifies Telnet | |
249 and rlogin buffers. | |
250 | |
251 An analogous feature lets you specify buffers which should be | |
252 displayed in their own individual frames. @xref{Special Buffer Frames}. | |
253 | |
254 @node Change Window | |
255 @section Deleting and Rearranging Windows | |
256 | |
257 @table @kbd | |
258 @item C-x 0 | |
259 Delete the selected window (@code{delete-window}). The last character | |
260 in this key sequence is a zero. | |
261 @item C-x 1 | |
262 Delete all windows in the selected frame except the selected window | |
263 (@code{delete-other-windows}). | |
264 @item C-x 4 0 | |
265 Delete the selected window and kill the buffer that was showing in it | |
266 (@code{kill-buffer-and-window}). The last character in this key | |
267 sequence is a zero. | |
268 @item C-x ^ | |
269 Make selected window taller (@code{enlarge-window}). | |
270 @item C-x @} | |
271 Make selected window wider (@code{enlarge-window-horizontally}). | |
272 @item C-x @{ | |
273 Make selected window narrower (@code{shrink-window-horizontally}). | |
274 @item C-x - | |
275 Shrink this window if its buffer doesn't need so many lines | |
276 (@code{shrink-window-if-larger-than-buffer}). | |
277 @item C-x + | |
278 Make all windows the same height (@code{balance-windows}). | |
279 @item Drag-Mouse-1 | |
280 Dragging a window's mode line up or down with @kbd{Mouse-1} changes | |
281 window heights. | |
282 @item Mouse-2 | |
283 @kbd{Mouse-2} in a window's mode line deletes all other windows in the frame | |
284 (@code{mouse-delete-other-windows}). | |
285 @item Mouse-3 | |
286 @kbd{Mouse-3} in a window's mode line deletes that window | |
35954
c869b148aa3f
Document what does mouse-3 do on the mode line if there's only one window.
Eli Zaretskii <eliz@gnu.org>
parents:
35188
diff
changeset
|
287 (@code{mouse-delete-window}), unless the frame has only one window, in |
c869b148aa3f
Document what does mouse-3 do on the mode line if there's only one window.
Eli Zaretskii <eliz@gnu.org>
parents:
35188
diff
changeset
|
288 which case it buries the current buffer instead and switches to another |
c869b148aa3f
Document what does mouse-3 do on the mode line if there's only one window.
Eli Zaretskii <eliz@gnu.org>
parents:
35188
diff
changeset
|
289 buffer. |
25829 | 290 @end table |
291 | |
292 @kindex C-x 0 | |
293 @findex delete-window | |
294 To delete a window, type @kbd{C-x 0} (@code{delete-window}). (That is | |
295 a zero.) The space occupied by the deleted window is given to an | |
296 adjacent window (but not the minibuffer window, even if that is active | |
297 at the time). Once a window is deleted, its attributes are forgotten; | |
298 only restoring a window configuration can bring it back. Deleting the | |
299 window has no effect on the buffer it used to display; the buffer | |
300 continues to exist, and you can select it in any window with @kbd{C-x | |
301 b}. | |
302 | |
303 @findex kill-buffer-and-window | |
304 @kindex C-x 4 0 | |
305 @kbd{C-x 4 0} (@code{kill-buffer-and-window}) is a stronger command | |
306 than @kbd{C-x 0}; it kills the current buffer and then deletes the | |
307 selected window. | |
308 | |
309 @kindex C-x 1 | |
310 @findex delete-other-windows | |
311 @kbd{C-x 1} (@code{delete-other-windows}) is more powerful in a | |
312 different way; it deletes all the windows except the selected one (and | |
313 the minibuffer); the selected window expands to use the whole frame | |
314 except for the echo area. | |
315 | |
316 You can also delete a window by clicking on its mode line with | |
317 @kbd{Mouse-2}, and delete all the windows in a frame except one window | |
318 by clicking on that window's mode line with @kbd{Mouse-3}. | |
319 | |
320 The easiest way to adjust window heights is with a mouse. If you | |
321 press @kbd{Mouse-1} on a mode line, you can drag that mode line up or | |
322 down, changing the heights of the windows above and below it. | |
323 | |
324 @kindex C-x ^ | |
325 @findex enlarge-window | |
326 @kindex C-x @} | |
327 @findex enlarge-window-horizontally | |
328 @vindex window-min-height | |
329 @vindex window-min-width | |
330 To readjust the division of space among vertically adjacent windows, | |
331 use @kbd{C-x ^} (@code{enlarge-window}). It makes the currently | |
332 selected window get one line bigger, or as many lines as is specified | |
333 with a numeric argument. With a negative argument, it makes the | |
334 selected window smaller. @kbd{C-x @}} | |
335 (@code{enlarge-window-horizontally}) makes the selected window wider by | |
336 the specified number of columns. @kbd{C-x @{} | |
337 (@code{shrink-window-horizontally}) makes the selected window narrower | |
338 by the specified number of columns. | |
339 | |
340 When you make a window bigger, the space comes from one of its | |
341 neighbors. If this makes any window too small, it is deleted and its | |
342 space is given to an adjacent window. The minimum size is specified by | |
343 the variables @code{window-min-height} and @code{window-min-width}. | |
344 | |
345 @kindex C-x - | |
346 @findex shrink-window-if-larger-than-buffer | |
347 The command @kbd{C-x -} (@code{shrink-window-if-larger-than-buffer}) | |
348 reduces the height of the selected window, if it is taller than | |
349 necessary to show the whole text of the buffer it is displaying. It | |
350 gives the extra lines to other windows in the frame. | |
351 | |
352 @kindex C-x + | |
353 @findex balance-windows | |
354 You can also use @kbd{C-x +} (@code{balance-windows}) to even out the | |
355 heights of all the windows in the selected frame. | |
356 | |
28551 | 357 @node Window Convenience |
358 @section Window Handling Convenience Features and Customization | |
359 | |
360 @findex winner-mode | |
30875 | 361 @cindex Winner mode |
362 @cindex mode, Winner | |
28551 | 363 @cindex undoing window configuration changes |
364 @cindex window configuration changes, undoing | |
36182
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
365 @kbd{M-x winner-mode} is a global minor mode that records the |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
366 changes in the window configuration (i.e. how the frames are |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
367 partitioned into windows), so that you can ``undo'' them. To undo, |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
368 use @kbd{C-x left} (@code{winner-undo}). If you change your mind |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
369 while undoing, you can redo the changes you had undone using @kbd{C-x |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
370 right} (@code{M-x winner-redo}). Another way to enable Winner mode is |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
371 by customizing the variable @code{winner-mode}. |
28551 | 372 |
373 @cindex Windmove package | |
374 @cindex directional window selection | |
30875 | 375 @findex windmove-right |
376 @findex windmove-default-keybindings | |
39268 | 377 The Windmove commands move directionally between neighboring windows in |
30875 | 378 a frame. @kbd{M-x windmove-right} selects the window immediately to the |
36182
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
379 right of the currently selected one, and similarly for the ``left,'' ``up,'' |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
380 and ``down'' counterparts. @kbd{M-x windmove-default-keybindings} binds |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
381 these commands to @kbd{S-right} etc. (Not all terminals support shifted |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
382 arrow keys, however.) |
28551 | 383 |
36182
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
384 Follow minor mode (@kbd{M-x follow-mode}) synchronizes several |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
385 windows on the same buffer so that they always display adjacent |
36263
11db0318031d
Remove redundant index entries.
Eli Zaretskii <eliz@gnu.org>
parents:
36185
diff
changeset
|
386 sections of that buffer. @xref{Follow Mode}. |
36182
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
387 |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
388 @vindex scroll-all-mode |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
389 @cindex scrolling windows together |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
390 @cindex Scroll-all mode |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
391 @cindex mode, Scroll-all |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
392 @kbd{M-x scroll-all-mode} provides commands to scroll all visible |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
393 windows together. You can also turn it on by customizing the variable |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
394 @code{scroll-all-mode}. The commands provided are @kbd{M-x |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
395 scroll-all-scroll-down-all}, @kbd{M-x scroll-all-page-down-all} and |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
396 their corresponding ``up'' equivalents. To make this mode useful, |
add12d9a298a
Major rewrite in Window Convenience node.
Richard M. Stallman <rms@gnu.org>
parents:
35954
diff
changeset
|
397 you should bind these commands to appropriate keys. |