Emacs Advent Calendar 09: Windows

Wed 2015-12-09

At first there is some Emacs specific terminology to clear up: What today in modern GUIs is called a "window" is a "frame" in Emacs. Those frames won't be the topic for today, but the things that Emacs calls "windows": Frames can be split into several windows, displaying exactly one buffer each.

Note that a buffer can appear in multiple windows. Changes made to the buffer in one window are also shown other associated windows.

A window can be split into two windows which will be positioned one above the other (C-x 2) or side by side (C-x 3).

To switch from one window to the next, use C-x o. The next window can be scrolled with C-M-v without giving focus to it. Note that the last key combination won't work on most text terminals, but will under X.

If you like the focus to follow mouse from one window to the next without having to click in the target buffer, set the variable mouse-autoselect-window to a non-nil value (M-x customize-variable <RET> mouse-autoselect-window <RET>).

You can make a window the only window in a frame with C-x 1. To remove the current window from a frame, press C-x 0. Windows can be resized most conveniently by clicking and dragging the mouse on the modeline and the divider, respectively. For key combinations to the same effect refer to the reference manual.

There are convenient versions of some commands already seen that perform an action in another window. These have a '4' stuck in their key sequence:

  • C-x 4 f visits a file in another window.
  • C-x 4 b switches to a buffer in some window.
  • C-x 4 r visits a file read-only in another window.
  • C-x 4 d opens a directory in another window (mentioned here for future reference, dired will be a topic later on).

More details on this topic can be found in section 20 (Windows) of the Emacs Reference Manual.

Tags:

This text by Ludger Sandig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.