How to reorganize a tmux layout?

By Romain Dorgueil

Short answer

tmux select-layout tiled            # apply the tiled (grid) layout now
tmux select-layout main-vertical    # one large pane left, the rest stacked right

prefix Space cycles through the five preset layouts; select-layout <name> jumps straight to one. After pulling several panes into a window and ending up with a lopsided split, select-layout tiled re-tiles everything into an even grid in one step.

Details

The five presets are even-horizontal (equal columns), even-vertical (equal rows), main-horizontal (one large pane on top, the rest in a row below), main-vertical (one large pane on the left, the rest in a column on the right), and tiled (an even grid). prefix Space runs next-layout and walks through them in that order, wrapping back to the start.

select-layout <name> skips the cycling and applies a named layout directly, which is the one you actually want in a script or after a reshuffle. Each layout also has a direct key binding: prefix M-1 even-horizontal, M-2 even-vertical, M-3 main-horizontal, M-4 main-vertical, M-5 tiled (M- is Alt).

A layout is applied once: tmux computes the pane sizes at that moment, then lets you resize freely afterwards. Splitting or closing a pane does not re-apply it. So the usual move after rearranging panes is to run select-layout tiled (or your layout of choice) again to clean up.

Verified on tmux 3.2a.

Related