Brian Rodriguez
Brian Rodriguez

Reputation: 4366

tmux bind shortcut to create a pane above or to the left?

Whenever I use tmux split-window -h/v, it creates the new split to the right/bottom, respectively. I want a command that creates the new split on the other side (i.e., to the left/top), but I can't find any simple answer for this anywhere... How can I bind this behavior into a shortcut?

What happens by default:

 _______                         _______
|       |                       |   |   |
|   *   | == split-window -h => |   | * |
|       |                       |   |   |
 -------                         -------

What I want a shortcut for:

 _______                         _______
|       |                       |   |   |
|   *   | ==        ?        => | * |   |
|       |                       |   |   |
 -------                         -------

Upvotes: 14

Views: 5105

Answers (2)

VanQator
VanQator

Reputation: 53

As above, but remember, tmux has a problem if you run it from PuTTY or from virtual machine. It works properly, but there's sometimes a problem with create, switching and resize panes due to lack of keys recognition.

Upvotes: 1

ichramm
ichramm

Reputation: 6642

As from version 2.0, tmux's split-window and join-window understand -b to create the pane to the left or above the target pane.

Split horizontally and place at the left:

tmux split-window -hb

Split vertically and place at the top:

tmux split-window -vb

Update:

From inside tmux you can use } for swapping the panels once you have split the window:

Example for vertical splitting:

Ctrl + B + %
Ctrl + B + }

Upvotes: 30

Related Questions