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 lets you revert to a previous pane configuration. (in emacs 23.2 [see Emacs 23.2 Features (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) ; 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: Restore Opened Files, Windows Config]

[see Emacs 24.4 New Features (released 2014-10)]

Move Cursor to Different Panes by Arrow

By default, you can move cursor to the next pane by Alt+x 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.

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

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/

Manage Windows Topic

  1. Split Windows
  2. Save Split Windows Configuration
  3. Effective Windows Management
  4. Make Buffer Flow Side-by-Side
  5. Restore Opened Files, Windows Config
  6. Set Default Window Size

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs


Emacs Lisp