windows.texi 12 KB

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