tmux: Swapping Windows and Rotating Panes

Here's a few handy shortcuts so you can rearrange whatever you're working on.
I’ve been using tmux now for ~10 years. It’s a critical piece of my development workflow. Being able to reposition windows and panes is important.
For windows you can press leader + < to bring up a little menu to perform
common actions on a window. If you press l or r from within that menu you
can swap the current window to the left or right.
If you have a bunch of windows and want to avoid swapping a few times to
position it you can press leader + : and then type swap-window -s 3 -t 1
where -s is the source index and -t is the target index.
For panes you can press leader + { or leader + } to move the current
pane up or down. You can also press leader + space to cycle the layout such
as changing a horizontal split into vertical.
I’ve tweaked a number of key binds with tmux in DotFriedRice but I’ve kept the default binds for swapping windows and panes. I don’t use them a ton but it’s good to know about them when needed.
The video below demonstrates these actions.
# Demo Video
Timestamps
- 0:23 – Swapping windows
- 1:10 – Swapping with a source and target
- 2:04 – Swapping panes
- 2:48 – Cycling the pane layout
Did you customize these binds? Let me know below.