Emacs: Save Split Windows Configuration

By Xah Lee. Date: . Last updated: .

This page is a tutorial on managing split windows in emacs.

If you don't know how to split windows, see Emacs: Split Windows Basics

Save Split-window Config for Current Session

winner-mode

winner-mode lets you revert to a previous pane configuration. (in emacs 23.2 〔➤see Emacs 23.2 Features (released 2010-05)〕)

Example use:

  1. Call winner-mode to turn it on.
  2. Call split-window-below.
  3. Call split-window-right.
  4. Now, remove all split panes by calling delete-other-windows.
  5. Now, you can go back to previous split pane config by calling winner-undoCtrl+c 】. There's also winner-redoCtrl+c 】.

If you want this functionality always, put in your emacs init file:

;; restore split pane config, winner-undo, winner-redo
(winner-mode 1) ; in GNU emacs 23.2

Using Register to Save Split-Window Config

You can save split-window config to register, like this:

Note: this doesn't work when you restart emacs, even if you have desktop-save-mode on.

Save Split-window Config Across Sessions

In Emacs 24.4, if you restart emacs, previous session's windows and split-panes are automatically restored.

This is done by desktop-save-mode. 〔➤see Emacs: Save/Restore Opened Files, Windows Configuration: desktop-mode〕 〔➤see Emacs 24.4 New Features (released 2014-10)

Flow Buffer from Left to Right Window

Emacs: Make Screen Flow Side-by-Side for Widescreen

Move Cursor to Different Panes by Arrow

By default, you can move cursor to the next pane by calling other-windowCtrl+x o】. The default key is hard to use. Also, there's no key to move cursor to previous pane.

You can put the following in your emacs init file. It'll let you move cursor by {【⇧ Shift+】, 【⇧ Shift+】, 【⇧ Shift+】, 【⇧ Shift+】}.

However, you'll lose shift select.

(progn
  (require 'windmove)
  ;; use Shift+arrow_keys to move cursor around split panes
  (windmove-default-keybindings)
  ;; when cursor is on edge, move to the other side, as in a torus space
  (setq windmove-wrap-around t )
)

Workflow Tip: Full-Screen vs Multiple Window

Emacs: Effective Windows Management

Thanks to Mark Hepburn and John D Cook.

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from my keyboard store.