Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

tmux: Swapping Windows and Rotating Panes

tmux-swapping-windows-and-rotating-panes.jpg

Here's a few handy shortcuts so you can rearrange whatever you're working on.

Quick Jump:

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.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments