To move a window to a different position in tmux, use move-window
or swap-window
. The shorthand command is :movew
followed by the destination index.
Ctrl+b :movew -t 2
Windows in tmux are like tabs in a traditional terminal, and sometimes you may want to reorder them for better organization. tmux provides several commands to move and reposition windows.
Press Ctrl+b followed by : to enter command mode, then:
movew -t N
Where N
is the destination index. This moves the current window to position N.
To move window at position 3 to position 1:
movew -s 3 -t 1
To swap the current window with window 0:
swap-window -t 0
To swap window 2 with window 4:
swap-window -s 2 -t 4
tmux doesn't have default keyboard shortcuts specifically for moving windows, but you can add these to your .tmux.conf
:
# Move window left bind-key -n C-S-Left swap-window -t -1 # Move window right bind-key -n C-S-Right swap-window -t +1
To avoid "Window X doesn't exist" errors when moving windows to edges, add the -r
flag to enable wraparound: swap-window -r -t -1