Moving a tmux window changes its position in the current session's window list without restarting the shell, editor, or long-running command inside it. Reordering windows keeps the status bar aligned with the way the session is actually being used, which makes prefix-number navigation faster and reduces wrong-window jumps.
The move-window command retargets an existing window to a different window index inside the same session. Current tmux releases still keep the default Ctrl-b . binding for moving the current window from the command prompt, but the direct command form is the clearest way to move a specific window, insert it before or after another one, or replace an occupied slot on purpose.
Window numbers belong to each session and often start at 0 unless base-index has been changed in the configuration. List the current windows before moving anything, because tmux refuses an occupied destination index unless -a, -b, or -k is used, and moving a window to an unused slot can leave a numbering gap until you renumber the session.
Related: How to create a window in tmux
Related: How to rename a window in tmux
Related: How to customize the tmux status bar
$ tmux list-windows -t demo 0: shell (1 panes) [80x24] [layout b25d,80x24,0,0,0] @0 1: logs- (1 panes) [80x24] [layout b25e,80x24,0,0,1] @1 2: editor* (1 panes) [80x24] [layout b25f,80x24,0,0,2] @2 (active)
The number before each colon is the window index used in the session:window target syntax for move-window.
$ tmux move-window -s demo:2 -t demo:3
-s selects the source window and -t selects the destination index, so demo:2 becomes window 3 in the demo session.
If the destination already exists, tmux stops with an error such as index in use: 1 instead of shifting windows automatically.
$ tmux list-windows -t demo 0: shell (1 panes) [80x24] [layout b25d,80x24,0,0,0] @0 1: logs- (1 panes) [80x24] [layout b25e,80x24,0,0,1] @1 3: editor* (1 panes) [80x24] [layout b25f,80x24,0,0,2] @2 (active)
The asterisk marks the current window, and the numbering gap shows that the move succeeded even though index 2 is now unused.
$ tmux move-window -r -t demo
This renumbers the session sequentially, so the same editor window returns from index 3 to index 2 in the example above.