Next: , Previous: Basic Window, Up: Windows


25.2 Splitting Windows

C-x 2
Split the selected window into two windows, one above the other (split-window-vertically).
C-x 3
Split the selected window into two windows positioned side by side (split-window-horizontally).
C-Mouse-2
In the mode line or scroll bar of a window, split that window.

The command C-x 2 (split-window-vertically) breaks the selected window into two windows, one above the other. Both windows start out displaying the same buffer, with the same value of point. By default the two windows each get half the height of the window that was split; a numeric argument specifies how many lines to give to the top window.

C-x 3 (split-window-horizontally) breaks the selected window into two side-by-side windows. A numeric argument specifies how many columns to give the one on the left. If you are not using scrollbars, a vertical line separates the two windows. You can customize its color with the face vertical-border. Windows that are not the full width of the screen have mode lines, but they are truncated. On terminals where Emacs does not support highlighting, truncated mode lines sometimes do not appear in inverse video.

You can split a window horizontally or vertically by clicking C-Mouse-2 in the mode line or the scroll bar. The line of splitting goes through the place where you click: if you click on the mode line, the new scroll bar goes above the spot; if you click in the scroll bar, the mode line of the split window is side by side with your click.

When a window is less than the full width, text lines too long to fit are frequent. Continuing all those lines might be confusing, so if the variable truncate-partial-width-windows is non-nil, that forces truncation in all windows less than the full width of the screen, independent of the buffer being displayed and its value for truncate-lines. See Display Custom.

Horizontal scrolling is often used in side-by-side windows. See Horizontal Scrolling.

If split-window-keep-point is non-nil, the default, both of the windows resulting from C-x 2 inherit the value of point from the window that was split. This means that scrolling is inevitable. If this variable is nil, then C-x 2 tries to avoid scrolling the text currently visible on the screen, by putting point in each window at a position already visible in the window. It also selects whichever window contains the screen line that the cursor was previously on. Some users prefer the latter mode on slow terminals.