I thought Moving tmux pane to window was the same question but it doesn't seem to be.

Coming from using GNU screen regularly, I'm looking for tmux to do the same things. On of the things I do regularly is have a couple of different windows open, one with some code open in vim, and a couple of terminals windows open to test the code, and sometimes a window or two for various other things. I split the screen vertically and will often have the vim window in the top pane and then one of the other windows in the bottom bane.

The main commands I then use are Ctrla,Tab to rotate among the panes and Ctrla,n to rotate between the windows within a pane. For instance, with vim in the top pane, I switch to the bottom pane and then rotate through the other terminals, doing whatever I need. The screen stays split the whole time.

The problem is I can't find comparable capability to screen's Ctrla,n in tmux. Switching windows seems to not work inside a pane, but jumps entirely. If the screen is split the only two options seem to be to jump to some window that isn't split and then split it or to do a sub-split of a pane. Neither are what I was looking for.

Suggestions (besides just sticking with screen)?

  • Your terminology is a little confusing. In tmux a window can be split into multiple panes. Are you trying to cycle between panes in a window with a keybind?
    – jasonwryan
    Oct 28, 2012 at 22:55
  • I was trying to follow the nomenclature of the tools, but I admit it is confusing. I know how to change focus from one pane to another. What I'm trying to find out is how to cycle what is displayed in a particular pane without otherwise changing the layout.
    – FooBar
    Oct 29, 2012 at 2:05
  • So to move content from one pane to another? Are you looking for swap-pane? If you are looking to emulate screen's Ctrl-a n, then the tmux equivalent is Ctrl-b n.
    – jasonwryan
    Oct 29, 2012 at 2:32

6 Answers 6


I believe what you are looking for is Ctrlb+(, , , ). Those will allow you to move between the panes.

  • 2
    I'm sorry, but I wasn't very clear. I've figure out how to move from panel to panel. In tmux Ctrl b + o functions about the same as Ctrl a + Tab in screen. What I'm looking for is the equivalent functionality as screen's Ctrl a + n.
    – FooBar
    Oct 29, 2012 at 1:56
  • 1
    @FooBar how about Ctrl-b+{ or Ctrl-b+}? That is about as close as I can find to that functionality. Pane's aren't done the same way in tmux as they are handled in screen.
    – sparticvs
    Oct 29, 2012 at 3:27
  • I often have trouble focusing the highlighted pane, say I have two panes, I often press ^b↑. How do I then actually focus the highlighted pane such that another will be captured by the shell, not tmux? Nov 17, 2016 at 18:37
  • 1
    not in my case. that just does resize the current pane Oct 13, 2020 at 9:11
  • @KansaiRobot what shell are you running?
    – sparticvs
    Feb 8, 2021 at 0:29

tmux and screen have different models so there is no exact equivalent.

In screen terms, a split lets you display multiple windows at the same time. next (C-a n) rotates windows through the active part of the split; this lets you rotate “hidden” windows through the active region of the split.

In tmux terms, a split divides a window into one or more panes. Each part of a split window is an individual pane, panes are never hidden (if a window is selected (visible) all its panes are, too), and a pane can only be used in a single split of one window (a pane can not be in multiple windows, and it can not be in multiple splits of the same window). There are commands to move panes around in (or between) windows, but not in an identical way to next in screen.

You could use a binding like the following to arrange a similar effect:

bind-key C-n swap-pane -s :+.top \; rotate-window -Ut :+

You will probably want to put this in your ~/.tmux.conf file, but you can just type/paste it after Prefix : to bind it in your current server instance.

To use the binding, pick your “main window”, split it, create a “pane container” window immediately after the “main window”, then use the binding to rotate any pane in the “main window” among the group in the “pane container” window.

Here is how you might create the setup:

  • Pick a window to use as your “main window”. Start (e.g.) Vim in it.

  • Split your “main window” into two panes.

    E.g. Prefix " (:split-window)

    You can use this pane as your testing window (or log viewer, or whatever).

  • Create a new window (the “pane container”) immediately after your main window.

    E.g. Prefix c (:new-window)

    It is important that no other window gets between the indexes of the “main window” and the “pane container” window (+ in the window specifiers used in the bound commands means “the next higher numbered window”).

  • Split this window into a number of panes. To rotate through three panes, split this window into two panes (the third pane is the one in the “main window”).

    Maybe you need a shell for git, and a shell for running a database interface. Put each in a separate pane in this “pane container” window.

  • Switch back to your “main window”. Select the pane that you want to “rotate out”.

    You can use Prefix Up/Down/Left/Right to move among the panes.

  • Invoke the binding to swap the current pane with the first pane in “pane container” window and (“behind the scenes”) rotate the panes inside the “pane container” window (so that the next time you run the binding, the first command swaps with the “next” pane in the sequence).

    Prefix Control-n (the binding use C-n, but you could change this to whatever you like).

  • To scroll backwards through the panes, you can use the below:

bind-key C-p swap-pane -s :+.bottom \; rotate-window -Dt :+
  • Thank you! Great explanation and your suggested binding does appear to at least replicate the functionality I was looking for.
    – FooBar
    Nov 1, 2012 at 1:10
  • Excuse me, how might one full size a pane and then swap back to the previous arrangement Oct 12, 2013 at 18:11
  • 1
    @JamesAndino: tmux 1.8 has resize-pane -Z (by default, bound to Prefix + z) that temporarily “zooms” a pane to be the full size of the window. For version prior to 1.8 there was no built-in way to do it; others have crafted scripted solutions from other built-in commands (e.g. some of the answers to the SU question “Maximizing” a pane in tmux). Oct 12, 2013 at 19:46
  • ty, compiled and loaded Oct 13, 2013 at 4:24
  • 5
    I believe C-b o cycles panes. Jul 23, 2014 at 15:01

use bind -r, so you can press the prefix once, then other keys in a sequence to locate your pane. The timeout could be adjusted by repeat-time. Check man tmux

bind -r Tab select-pane -t :.+

If you prefer hjkl,

bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R

Put the following code in your .tmux.conf:

# cycle prev/next pane
bind -n S-right select-pane -t :.+
bind -n S-left select-pane -t :.-

Reload config, then you can press (directly without prefix key) Shift+ to cycle panes in clockwise direction, and Shift+ to cycle in reversed direction.

Tested in Tmux 2.8.

In case you don't want to edit the config, prefix+o is the default key binding for clockwise cycle. I occasionally found this key binding, then I get the command from tmux list-keys and use it for my own key bindings:

bind-key    -T prefix       o                 select-pane -t :.+

Here is a small conf that allows you to move to another pane or windows by using the shortcuts ALT or SHIFT + arrow. No need to use the prefix key. It's confortable!

## NAVIGATION: ############################

# Switch panes 
# Usage: "ALT+arrow keys" (without prefix key)
# from https://gist.github.com/spicycode
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Switch windows 
# usage: "SHIFT+arrow" (without prefix key)
bind -n S-Left  previous-window
bind -n S-Right next-window

You could also be interested by the following code that allow panes navigation by mouse. (usage: key prefix + m to turn on, M to turn it off)

## MOUSE CONTROL: #########################
set -g mode-mouse off
set -g mouse-resize-pane off
set -g mouse-select-pane off
set -g mouse-select-window off

# Toggle mouse on 
bind m \
    set -g mode-mouse on \;\
    set -g mouse-resize-pane on \;\
    set -g mouse-select-pane on \;\
    set -g mouse-select-window on \;\
    display 'Mouse: ON'
# Toggle mouse off
bind M \
    set -g mode-mouse off \;\
    set -g mouse-resize-pane off \;\
    set -g mouse-select-pane off \;\
    set -g mouse-select-window off \;\
    display 'Mouse: OFF'

this config has been tested on Tmux 1.6 to 1.9.


This answers gives you two panes, where both panes hold the same set of windows, but each pane can switch between windows independently.

The tmux approach is to use three sessions:

  • an outer session for the panes,
  • an inner session for the windows (you can attach to this from one pane),
  • a secondary view onto the inner session (for the other pane).

Yes this is UNIX philosophy gone mad. Let's get started:

# Create a session to hold the multiple windows
$ tmux new-session -s inner

    <Ctrl-b> c   to create a few windows, run some things

    <Ctrl-b> d   to detach, but leave it running

# Create a session to hold multiple panes (the view)
$ tmux new-session -s outer

    <Ctrl-b> "   to split

# Open the inner session in the current (bottom) pane
$ unset TMUX ; tmux attach -t inner

Now you can switch to the top pane and open Vim as usual. To cycle through the windows in the inner session (the lower pane) you will need to use Ctrl-b Ctrl-b n and p.

Aside: That is a bit unwieldy but you could always change the prefix of the outer session, e.g. to Ctrl-a, like this:

<Ctrl-b> :set-option prefix C-a

Then it would just be Ctrl-b n and p to cycle the inner windows, and Ctrl-a o to cycle the outer panes.

OK now, instead of opening Vim in the top pane, let's connect again to your inner session. Quit vim, and this time use a new-session command (notably with -t not -s):

$ tmux new-session -t inner

Voila! You can now cycle through windows on both the top and bottom panes.

The reason we must use new-session -t the second time is that if we were to simply do attach -t again, then the top and bottom panes would be synchronized, always showing the same window, which is not what you want. To let this pane move through windows independently of the other pane, we create a new "view" session but connect its back end directly to the existing session that holds the windows. This is also known as "grouped sessions". (By the way, that link also suggests using [un]link-window to move windows between sessions.)

Of course for symmetry, you could have run tmux new-session -t inner in the bottom pane too, instead of attach. In that case you would be running 4 instances of tmux (plus one more tmux process for the server)!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .