To swap or exchange panes in tmux, press Ctrl+b
followed by {
to move the current pane left/up or }
to move it right/down. For more control, use the swap-pane
command.
Swapping panes allows you to rearrange your tmux workspace without closing and recreating panes. This is useful for organizing related tasks or prioritizing your workflow by moving important panes to more prominent positions.
Ctrl+b {
- Move the current pane left (or up if arrangement doesn't allow left)Ctrl+b }
- Move the current pane right (or down if arrangement doesn't allow right)Ctrl+b :
then type swap-pane -s 2 -t 3
- Swap pane 2 with pane 3Ctrl+b :
then type swap-pane -U
- Swap with previous pane (up in the layout)Ctrl+b :
then type swap-pane -D
- Swap with next pane (down in the layout)To see pane numbers (needed for the swap-pane command):
Ctrl+b q
- Display pane numbers briefly Create more intuitive key bindings for swapping panes by adding these lines to your ~/.tmux.conf
:
# Swap current pane with the pane in the specified direction bind-key M-Up swap-pane -U bind-key M-Down swap-pane -D bind-key M-Left swap-pane -U bind-key M-Right swap-pane -D
Then use Alt+Arrow keys
with the prefix (Ctrl+b
) to swap in that direction.
Instead of swapping individual panes, you can also cycle through different layout arrangements:
Ctrl+b Space
- Cycle through available layoutsCtrl+b Alt+1
- Even horizontal layoutCtrl+b Alt+2
- Even vertical layoutCtrl+b Alt+3
- Main horizontal layoutCtrl+b Alt+4
- Main vertical layoutCtrl+b Alt+5
- Tiled layout