57

When I have a tmux window vertically split into two panes, how can i spawn a new third horizontal pane that stretches over the full width?

e.g. How do I get from this:

Ctr-b %

+–––––––––+–––––––––+
|         |         |
|         |         |
|         |         |  
|         |         |
|         |         |
+–––––––––+–––––––––+

to this?

Ctr-b %
Ctr-b ...now what?

+–––––––––+–––––––––+
|         |         |
|         |         |
|         |         |  
|         |         |
|         |         |
+–––––––––+–––––––––+
|                   |
|                   |
+–––––––––––––––––––+

instead of this?

Ctr-b %
Ctr-b "

+––––––––+––––––––––+
|        |          |
|        |          |  
|        |          |
|        |          |
|        |          |
|        +––––––––––+
|        |          |  
|        |          |
+––––––––+––––––––––+

Note: I don't want to cycle through all possible layout combinations via Ctr-b Space to eventually get to the desired layout - it should be achieved with as much brevity as possible.

1
  • it's amazing that this isn't a solved problem. All of the answers below so far are completely useless and don't address your actual question :-(
    – rob3c
    Jun 2, 2018 at 20:25

7 Answers 7

37

tmux 2.3 supports the -f switch in split-window which does exactly what you are looking for (check man here):

The -f option creates a new pane spanning the full window height (with -h) or full window width (with -v), instead of splitting the active pane.

For example, in your case:

1) ctrl-b %

+–––––––––+–––––––––+
|         |         |
|         |         |
|         |         |  
|         |         |
|         |         |
|         |         |
|         |         |
|         |         |
+–––––––––––––––––––+

2) ctrl-b :splitw -fv

Note that after ctrl-b :, you will be typing in the tmux command-prompt (look at the bottom bar).

+–––––––––+–––––––––+
|         |         |
|         |         |
|         |         |  
|         |         |
+–––––––––+–––––––––+
|                   |
|                   |
|                   |
+–––––––––––––––––––+
2
  • 4
    This should be accepted answer Sep 14, 2021 at 13:54
  • Is there any way to make this a hot key combination? E.g. Ctrl-B + " + "
    – ILIV
    Jul 17 at 7:43
30

You can use one of the five preset layout modes (tiled) to achieve this. From your starting point (a single vertical split), open a new pane, which by default will split the active pane and then arrange the panes into tiled mode:

Ctrlb,Alt5

From man tmux:

M-1 to M-5    Arrange panes in one of the five preset layouts: even-horizontal,even-vertical, main-horizontal, main-vertical, or tiled.

You could optionally add a select-layout tiled to a keybind in your .tmux.conf if this was a layout you wanted regularly.

3
  • 2
    I cried when got to know that tmux has presets after years of using it. Jul 23, 2018 at 12:14
  • What keys do you press on Mac? Ctrl b, Option 5 is not working for me. Feb 25, 2019 at 22:48
  • 2
    It's Ctrl b Esc 5 in Mac
    – Hritik
    Dec 17, 2021 at 8:47
22

Get a newer version of tmux (at least 2.3).

From the man page:

The -f option creates a new pane spanning the full window height (with -h) or full window width (with -v), instead of splitting the active pane.

1
  • 4
    good answer, but an example or two would be most illustrative
    – dbkeys
    Aug 7, 2019 at 13:28
5

If you'd like to spawn a new third horizontal pane that stretches over the full width, I suggest you try this

Ctrl-b "

or to cycle through

Ctrl-b space

3
  • 1
    Thank you for your suggestion. I don't want to cycle through all possible layouts though, but simply spawn a third pane with the desired layout and position. But maybe your suggestion is the only possible solution to achieve this (which I hope it is not :)
    – jottr
    Apr 11, 2014 at 23:13
  • @elementz did the ctrl-b " double quotes work??
    – kmassada
    Apr 12, 2014 at 11:55
  • No. That ctr-b " creates what you can see in my third example above.
    – jottr
    Apr 12, 2014 at 12:14
4

I wound up here looking for a way to move an existing pane to the left, right, top, or botton of the terminal and span the full height or width.

If anyone else ends up here looking for the same thing, the solution is to use split-window, swap-pane, and then kill-pane together.

For example, add this to your .tmux.conf file:

# Pane moving
bind S-Left  split-window -hbf \; swap-pane -t ! \; kill-pane -t !
bind S-Right split-window -hf  \; swap-pane -t ! \; kill-pane -t !
bind S-Up    split-window -bf  \; swap-pane -t ! \; kill-pane -t !
bind S-Down  split-window -f   \; swap-pane -t ! \; kill-pane -t !

Then you can use ctrl+b, shift+left to move the current pane to the left side of the terminal, spanning its full height.

1
  • I prefer, UDLR, but these work great.
    – Jess
    May 7, 2020 at 20:45
3

Old question but wanted to add, if there is a layout you want to use often you can use

   tmux list-windows

to give you the current layout (this will be a string like c904,273x74,0,0{81x74,0,0[81x29,0,0,1,81x21,0,30,2,81x22,0,52,3],191x74,82,0,0})

Then pass that string to select-layout to apply it. Look for select-layout in the man page for more info.

1
  • that's a great supplement! Jul 17, 2019 at 9:13
1

Ctrl + B then " (double quotes) to split into two horizontal windows

Ctrl + B "o" to switch back to top window (check your cursor, that will tell you where you are)

Ctrl + B then % (shift + 5) to split the top window

That should work with the default key bindings.

1
  • 6
    Thx for trying to answer my question, but the starting point is NOT a blank slate, but an already vertically split window.
    – jottr
    Apr 11, 2014 at 23:08

You must log in to answer this question.

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