tmux offers five built-in window layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, and tiled. To change layouts, press Ctrl+b Space to cycle through them, or use Ctrl+b : select-layout layout-name
to choose a specific layout. You can also create custom layouts using select-layout -E
to evenly size panes or manually adjust pane sizes with Ctrl+b Alt+arrow keys.
# Cycle through layouts Ctrl+b Space # Select specific layout Ctrl+b :select-layout even-horizontal
tmux layouts determine how multiple panes are arranged within a window. Understanding and manipulating these layouts can significantly improve your workflow efficiency, especially when working with multiple commands or tasks simultaneously.
tmux provides five standard layouts:
The quickest way to change layouts is to cycle through them:
# Cycle through all layouts Ctrl+b Space
Each press will switch to the next layout in the sequence, allowing you to quickly find the arrangement that works best for your current task.
To switch directly to a specific layout:
# In tmux command mode (Ctrl+b :) select-layout even-horizontal select-layout even-vertical select-layout main-horizontal select-layout main-vertical select-layout tiled
For the main-horizontal and main-vertical layouts, you can adjust the size of the main pane:
# Increase main pane height (for main-horizontal) Ctrl+b :resize-pane -D 10 # Increase main pane width (for main-vertical) Ctrl+b :resize-pane -R 10
You can also set the number of panes to show in the main area:
# Set how many panes to show in the main area Ctrl+b :set-window-option main-pane-height 20 Ctrl+b :set-window-option main-pane-width 100
You can manually resize panes using these key combinations:
For more precise control, you can use the command mode:
# Resize the current pane down by 10 cells Ctrl+b :resize-pane -D 10 # Resize the current pane up by 10 cells Ctrl+b :resize-pane -U 10 # Resize the current pane left by 10 cells Ctrl+b :resize-pane -L 10 # Resize the current pane right by 10 cells Ctrl+b :resize-pane -R 10
You can create custom layouts by arranging panes as desired and then saving the layout:
# First, arrange your panes the way you want them # Then, save the current layout Ctrl+b :select-layout -E # This evenly spaces the current layout # To save the layout for later use Ctrl+b :run-shell "tmux list-windows -F \"#{window_layout}\" > ~/.tmux-layout"
To restore a saved layout:
# From your saved layout file Ctrl+b :run-shell "tmux select-layout \"$(cat ~/.tmux-layout)\""
After manually resizing panes, you can redistribute them evenly:
# Make all panes equally sized while preserving arrangement Ctrl+b :select-layout -E
Create custom key bindings for your favorite layouts:
# Add to ~/.tmux.conf # Horizontal split layout bind-key H select-layout even-horizontal # Vertical split layout bind-key V select-layout even-vertical # Main programming layout (large left pane, two right panes) bind-key P select-layout main-vertical \; resize-pane -t 0 -x 120
This configuration lets you quickly switch between common layouts with Ctrl+b H, Ctrl+b V, and Ctrl+b P.