Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know I can swap windows using swap-window -d *source* -t *dest*, but I'd like to be able to swap the current window with the window to the left/right (effectively, 'move' a window left and right through the list). In particular, I want to map this command to a shortcut in my tmux.conf. I think I could do this if there was a way to reference the current window number in the tmux.conf file and do something like this:

swap-window -t *cur_window -1*

Is this possible?

share|improve this question
up vote 2 down vote accepted

The tmux manpage describes the target-window syntax accepted by swap-window’s -s and -t options. Specifically, you can use + and - to refer to the next and previous window numbers.

Thus, you might bind < and > to move windows left and right like this:

bind-key < swap-window -t -
bind-key > swap-window -t +
share|improve this answer
Thank you! Not sure how I missed that. – TimmyJ Feb 20 '13 at 14:19

Chris's answer is great!

Just some improve:

bind-key -r < swap-window -t -
bind-key -r > swap-window -t +

Flag -r indicates this key may repeat. This is may more convenient.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.