To rearrange tmux panes, use Ctrl+b { to swap the current pane with the previous one, or Ctrl+b } to swap with the next one. You can also use Ctrl+b Space to cycle through different predefined layouts. For more precise control, use Ctrl+b : followed by swap-pane -s 1 -t 2
to swap panes by index, or move-pane -t 2
to move the current pane to window 2.
# Swap current pane with previous Ctrl+b { # Swap current pane with next Ctrl+b } # Cycle through layouts Ctrl+b Space # Swap panes by index Ctrl+b :swap-pane -s 2 -t 3
Rearranging panes in tmux allows you to customize your workspace layout for optimal productivity. There are several ways to move, swap, and rearrange panes to create your ideal setup.
The simplest way to rearrange panes is to swap them with adjacent panes:
You can press these key combinations multiple times to move a pane several positions.
tmux provides several predefined layouts that you can cycle through:
# Cycle through layouts Ctrl+b Space
The available layouts include:
even-horizontal
- Panes arranged side by side, all the same widtheven-vertical
- Panes stacked on top of each other, all the same heightmain-horizontal
- One large pane at the top, smaller panes at the bottommain-vertical
- One large pane on the left, smaller panes on the righttiled
- All panes arranged evenly in a gridTo select a specific layout directly:
# Select a specific layout Ctrl+b :select-layout main-vertical # Or use the shorthand Ctrl+b M-1 # main-horizontal Ctrl+b M-2 # main-vertical Ctrl+b M-3 # even-horizontal Ctrl+b M-4 # even-vertical Ctrl+b M-5 # tiled
For more precise control, use the swap-pane
command:
# Swap panes by index Ctrl+b :swap-pane -s 2 -t 3 # Swap pane 2 with pane 3 # Swap current pane with a specific pane Ctrl+b :swap-pane -t 0 # Swap current pane with pane 0 # Swap with pane in a different window Ctrl+b :swap-pane -s 1.2 -t 2.1 # Swap pane 2 in window 1 with pane 1 in window 2
In these commands:
-s
specifies the source pane (what you want to move)-t
specifies the target pane (where you want to move it)-s
, the current pane is used as the source You can move a pane to a different window using the move-pane
command:
# Move current pane to window 2 Ctrl+b :move-pane -t :2 # Move current pane to a specific window and pane position Ctrl+b :move-pane -t mysession:2.1 # Move pane and create a new window if it doesn't exist Ctrl+b :move-pane -t :+ # Join pane from another window to current window Ctrl+b :join-pane -s :3.2 # Join pane 2 from window 3 to current window
You can also break a pane out into its own window:
# Break current pane into a new window Ctrl+b :break-pane # Break with options Ctrl+b :break-pane -n "new-window-name" -t 3 # Break into window index 3
If mouse support is enabled, you can drag and drop panes to rearrange them:
# Enable mouse support Ctrl+b :set -g mouse on
With mouse support enabled, you can: