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 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: 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 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 )

Workflow Tip: Full-Screen vs Multiple Window

Emacs: Effective Windows Management

Thanks to Mark Hepburn and John D Cook.

Like my tutorial? Put $5 at patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs