How to split a tmux window into panes?

By Romain Dorgueil

Short answer

tmux split-window -h   # panes side by side (left / right)
tmux split-window -v   # panes stacked (top / bottom)

From the keyboard with the default prefix, prefix % splits side by side and prefix " splits top and bottom.

Details

A tmux window can hold several panes, each running its own shell. split-window cuts the active pane in two and starts a new shell in the freed half.

The flag names are the classic tmux trap. -h reads as “horizontal” but gives you a vertical divider, so the panes end up side by side. -v gives a horizontal divider, stacking the panes top and bottom. The flag describes the axis of the cut, not the visual orientation of the split. The keyboard mnemonics are easier to remember: % looks like a vertical bar, " like two stacked marks.

Because those flag names are easy to forget, I rebind the splits to keys that look like the result:

# ~/.tmux.conf
bind | split-window -h   # | is the vertical divider: panes side by side
bind - split-window -v   # - is the horizontal divider: panes stacked

Now prefix | splits side by side and prefix - stacks, with the key matching the layout. The default % and " still work. Add -c "#{pane_current_path}" to either bind to open the new pane in the current directory.

Verified on tmux 3.2a: from a 200x50 window, split-window -h produces two panes left/right (widths 100 and 99), and split-window -v produces two panes top/bottom (heights 25 and 24). The bind | ... and bind - ... lines load with no parse error and show up in the prefix key table.

A few options worth knowing: -c "#{pane_current_path}" opens the new pane in the current pane’s directory, -b inserts the new pane before the current one (left or top instead of right or bottom), and -l 30 or -l 30% sets its size.

Related