Emacs: Split Windows

By Xah Lee. Date: . Last updated: .
emacs split windows basics 2015
emacs split windows.
Emacs Split Window Commands
PurposeCommand NameKey
split top/bottomsplit-window-belowCtrl+x 2
split left/rightsplit-window-rightCtrl+x 3
unsplit alldelete-other-windowsCtrl+x 1
remove current panedelete-windowCtrl+x 0
move cursor to next paneother-windowCtrl+x o

Note, emacs terminology of window/frame is reversed from modern meaning.

Easy Keys for Split Window

Split/unsplit window panes are some of the most frequently used commands, because emacs often generates output in a splits window. [see Emacs Command Frequency Statistics]

I recommend setting easy keys for them.

Put the following in your emacs init file.

;; easy keys for split windows
(global-set-key (kbd "M-3") 'delete-other-windows) ; 【Alt+3】 unsplit all
(global-set-key (kbd "M-4") 'split-window-below)
(global-set-key (kbd "M-$") 'split-window-right)
(global-set-key (kbd "M-RET") 'other-window) ; 【Alt+Return】 move cursor to next pane
(global-set-key (kbd "M-0") 'delete-window)  ; remove current pane

[see Emacs: How to Define Keys]

Note: I do not recommend keys like 【Alt+1】 or 【Ctrl+1】 , because that got me Repetitive Strain Injury. [see Programer Hand Health: vi Esc Key Syndrome]

Adjust Split Pane Size

You can adjust the split pane size by mouse dragging the mode line (status bar). For windows split left/right, drag the split position on the horizontal mode line.

Or, you can use keys. Here's the commands:

Emacs Pane Size Adjustment Commands
enlarge-windowCtrl+x ^increase height
shrink-windowdecrease height
enlarge-window-horizontallyCtrl+x }increase width
shrink-window-horizontallyCtrl+x {decrease width
shrink-window-if-larger-than-bufferCtrl+x -shrink a window to fit its content.
balance-windowsCtrl+x + make all panes same width/height

Most of these commands also take a argument. Alt+x universal-argumentCtrl+u】 first then type a number, then, call the command that adjust window size.

If you use these commands often, you probably want to give them a easy key such as F8, so you can hold it to enlarge/shrink window size. [see Emacs: How to Define Keys]

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