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

Save Split-window Config for Current Session

winner-mode

winner-mode lets you revert to a previous pane configuration. (in emacs 23.2 (released 2010-05))

Example use:

  1. Alt+x winner-mode to turn it on.
  2. Alt+x split-window-below.
  3. Alt+x split-window-right.
  4. Now, remove all split panes by Alt+x delete-other-windows.
  5. Now, you can go back to previous split pane config by Alt+x 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) ; 

Using Register to Save Split Windows Config

You can save windows config to register, like this:

Note: register content is not saved when you quit emacs, even if you have desktop-save-mode on.

Save Split-window Config Across Sessions

In Emacs 24.4 (released 2014-10) or later, if you restart emacs, previous session's windows and split-panes are automatically restored. This is because desktop-save-mode is on by default. [see Emacs: Restore Opened Files, Windows Config]

Thanks to Mark Hepburn https://plus.google.com/b/113859563190964307534/110262280296887306226/about and John D Cook http://www.johndcook.com/blog/2012/03/07/shuffling-emacs-windows/

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Tutorial

Quick Start

Manage Windows

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc