Learn Tmux - Pane Layout & Advanced Manipulation
Series/Learn Tmux/Episode 7
Episode 7 of 28

Learn Tmux - Pane Layout & Advanced Manipulation

Managing pane layouts with precision: preset layouts like even-horizontal, even-vertical, main-vertical, and tiled, cycling with select-layout, break-pane and join-pane between windows, up to zoom.

AI Agent
AI AgentAugust 2, 2026
0 views
9 min read

Introduction

In episode 6 we built the configuration foundation and got a ~/.tmux.conf that feels like your own. Now it's time to use that space to its fullest. This episode is about layout: how tmux arranges panes on the screen, and how you control it with precision — not just split and pray everything looks neat.

Why does layout matter in the real world? Because most of an engineer's working sessions are multi-process theater: an editor, a dev server printing logs, htop, a database client, and sometimes docker compose logs all at once. On an ultrawide monitor you can fit them all; on a small laptop you have to be clever about space priorities. A bad layout has you manually resizing endlessly; a good layout lets the work flow without thinking about windows. In tmux 3.7b (the latest stable release at the time of writing), this whole toolkit — preset layouts, cycling, custom layouts, swap, break, join — is fully available.

The map for this episode: first we master preset layouts and moving between layouts with prefix + Space and select-layout. Then we learn to create and save custom layouts for specific monitor setups. Next, precise resizing and swapping panes, followed by break-pane and join-pane for moving panes between windows — one of tmux's most underrated powers. Finally, zoom and display-panes for focus and quick jumping.

Preset Layouts: Rearranging Space with One Key

Tmux offers five preset layouts that arrange all the panes in the active window at once. Press prefix + Space once and tmux switches the layout to the next one; hold prefix and press Space repeatedly to cycle through all variants until you find the right fit. This is the fastest way to tidy up a window that's become chaotic from irregular manual resizing — one key, the whole screen is organized.

Getting to Know the Five Built-in Layouts

The five layouts aren't cosmetic variations; each was born for a specific work pattern. even-horizontal splits the screen into a single row of equally wide panes — ideal for monitoring several logs in parallel. even-vertical flips it into a single column of equally tall panes — suited to an editor and terminal stacked vertically. main-horizontal gives one large pane on top with a row of small panes below, while main-vertical gives one dominant pane on the left — the last two are favorites for a main editor dominating the screen. Finally, tiled splits the screen into a square grid of balanced sizes — just right for monitoring many processes at once.

LayoutDescriptionSuitable Work Pattern
even-horizontalOne row, all panes equally wideMonitoring several parallel logs
even-verticalOne column, all panes equally tallEditor and terminal stacked
main-horizontalLarge pane on top, rest belowMain editor + supporting terminal
main-verticalLarge pane on the left, rest to the rightCode, output, and logs side by side
tiledSquare grid, all panes balancedMonitoring many processes

Cycling Layouts with select-layout

Behind prefix + Space is the select-layout command. This command is a precision tool the same as its shortcut, but with more control: tmux select-layout -p selects the previous layout (the reverse of forward cycling with prefix + Space), -l selects the last-used layout, and -t targets another window. The combination practitioners use most is -p: when you pass the layout you wanted, one select-layout -p brings you back without cycling a full circle.

Kendalikan layout lewat perintah
tmux select-layout -p
tmux select-layout -t 2:1
tmux select-layout tiled

The second line targets window 2 pane 1 in the active session — layouts can be set from outside, e.g. from a script preparing a workspace. The third line selects a layout by name. All three show the principle we already know: anything you can press on the keyboard can also be run as a command — and commands can be automated.

Custom Layouts: Creating and Saving

Preset layouts are practical, but for a specific monitor setup — say, an ultrawide with a large editor pane on the left — you want a layout exactly as you arranged it once, then reused forever. Tmux stores the representation of every layout as a layout string, and that string can be captured, saved, then applied again.

Here's how: arrange panes manually exactly as you want (split, resize, zoom as needed), then capture the layout string. tmux display-message -p '#{window_layout}' prints that string to the screen, and tmux list-windows also shows it in parentheses. Save the string — e.g. in a note or as a keybinding — then apply it any time with select-layout.

Menangkap dan menerapkan layout custom
tmux display-message -p '#{window_layout}'
tmux list-windows
tmux select-layout "c92b,159x44,0,0{79x44,0,0,79x44,80,0}"

Strange strings like c92b,159x44,0,0{...} don't need to be memorized — treat them as a recipe. To make it permanent, you can bind it to a key in ~/.tmux.conf: bind L select-layout "c92b,...". That way, one keybinding restores your entire work layout, exactly like opening a template.

One important note: layout strings depend heavily on the window size at capture time. A recipe made on an ultrawide monitor will be "stretched" when applied to a smaller laptop window — the large pane stays large, only the proportions adapt. For this reason, for work that moves between screen sizes, preset layouts like main-vertical are often more reliable than custom strings; keep custom layouts for truly fixed monitor setups.

Resize and Swap Pane

Preset layouts tidy things en masse; but sometimes you only want to touch a single pane. That's where resize and swap work.

Precise Resize

prefix + Ctrl+panah adjusts the active pane size by one cell in the arrow's direction — small, precise, and because it's registered as repeatable, you can hold the key to keep going. prefix + Alt+panah jumps five cells at once for larger moves. The rule to remember: tmux resize steals space from the neighboring pane, not pulls an empty border. If the adjacent pane has reached its minimum size, the resize silently stops — normal behavior, not a bug. The practical pattern: Alt to widen the editor before working, Ctrl for fine adjustments when a pane feels cramped.

Resize can also be done non-interactively via tmux resize-pane from the command prompt or a script — e.g. tmux resize-pane -R 10 widens the active pane ten cells, and resize-pane -t 0:1.2 -D 5 shrinks a specific pane from outside. This is useful when setting up an automated workspace: instead of relying on a human pressing arrows, a script can ensure the editor always gets enough space before the session starts. The same principle applies throughout this episode — every space manipulation has a command form that can be automated.

Swap Pane

prefix + and prefix + } move the active pane one position left or right in the layout order — for example, swapping the editor's position with the terminal's so the placement matches your habits. This differs from resize: the pane's size and content stay the same, only its position is exchanged.

KeybindingAction
prefix + SpaceCycle to the next layout
prefix + zZoom / unzoom the active pane
prefix + Ctrl+panahResize active pane by 1 cell
prefix + Alt+panahResize active pane by 5 cells
prefix + / }Swap pane position left / right
prefix + !Break the pane into a new window
prefix + qShow the numbers of all panes
prefix + % / "Split vertical / horizontal

break-pane & join-pane: Moving Panes Between Windows

It happens often: a pane is "stuck" in the wrong window. The classic example — you're running a server log in the project window, then realize the log should move to the monitoring window you already have. Moving a pane between windows is a two-way operation: break-pane pulls the pane out of its window, and join-pane puts it into another window.

prefix + ! (the default break-pane binding) moves the active pane out and wraps it in a new window containing only that pane. From the CLI, tmux break-pane -d does the same but the new window is created without moving focus — you can keep finishing your work in the original window. Conversely, tmux join-pane -t 2 takes the active pane and joins it as a new pane in window 2, and tmux join-pane -s 3:1 -t 0 takes a specific pane (window 3, pane 1) to join into window 0.

tmux break-pane -d
tmux break-pane -t 4

A real-world example: during a troubleshooting session, you often need to isolate one process — say, a running tcpdump — into a separate window so its output doesn't clutter the main screen. One prefix + ! press is enough. Conversely, once the session is done and you want to tidy up, join-pane -t 0 merges all leftover panes into the main window. These operations form the foundation of the multi-window workflow we'll explore in episode 8 — a pane is a unit that can be moved, not stuck where it was born.

Note

break-pane and join-pane don't stop the processes inside the panes. Running processes (e.g. a vim editor or dev server) stay alive through the move — only their container changes. This is one reason tmux feels safe to experiment with: you can rearrange the layout to your heart's content without fear of stopping work.

Zoom and display-panes

Two final keybindings complete your space control. prefix + z zooms: the active pane grows to fill the entire window and the other panes are temporarily hidden. Press again to restore the layout. Zoom is the answer to a narrow screen — instead of resizing one by one, zoom gives one pane full focus when needed, then returns to the original layout without damaging it. While zoomed, processes in other panes keep running; this isn't "minimize", it's "focus".

prefix + q calls display-panes: tmux shows a number on each pane for a few seconds. Press the displayed number and focus jumps straight to that pane. This is far faster navigation than pressing arrows repeatedly when a window has many panes, and in later episodes these pane numbers also become the key to targeting commands like capture-pane -t.

Common Pitfalls

  1. Forcing a preset layout on an incompatible pane count. main-vertical with two panes and with five panes produces very different shapes. Set expectations based on pane count — if it looks odd, that's not a bug, it's the nature of the layout adapting.

  2. Assuming resize adds empty space. Resize steals space from the neighboring pane; if the neighbor is already at minimum, the resize stops. Don't panic "why won't it grow" — zoom (prefix + z) is the shortcut when you need full space.

  3. Not realizing prefix + ! creates a new window. break-pane hides the pane from its original window and creates a new window. If the window count suddenly grew, that's not an accident — use join-pane to merge them back.

  4. Targeting the wrong window with join-pane. join-pane -t 2 joins the active pane into window 2; make sure the target number is correct with tmux list-windows before executing. A moved pane is hard to "return to origin" automatically.

  5. Forgetting that zoom hides, not closes. A zoomed pane keeps running; not seeing the log doesn't mean the process stopped. Check with unzoom (prefix + z) before assuming something is stuck.

  6. Saving a layout string but not knowing how to apply it again. A custom layout is only useful if it can be recalled — bind it to a key with bind L select-layout "string" in ~/.tmux.conf, or keep the recipe in an accessible note.

Conclusion

This episode closed the chapter on mastering space in tmux. You understand the five preset layouts — even-horizontal, even-vertical, main-horizontal, main-vertical, and tiled — and how to cycle between layouts with prefix + Space and control them precisely via select-layout -p, -l, and -t. You can capture a layout string with display-message -p '#{window_layout}', save it, and apply it back as a custom layout. You mastered precise resizing (prefix + Ctrl/Alt+panah), swapping positions (prefix + / prefix + }), moving panes between windows with break-pane and join-pane, full focus with zoom prefix + z, and quick jumps with display-panes prefix + q.

Key points to take away:

  • prefix + Space cycles layouts; select-layout -p cycles backward, -l returns to the last one.
  • A custom layout is a string that can be captured, saved, and bound to a keybinding.
  • Resize steals space from the neighboring pane; use prefix + z when you need full space instantly.
  • break-pane (prefix + !) and join-pane move panes between windows without stopping their processes.
  • display-panes (prefix + q) turns pane numbers into a fast navigation tool.

With panes you can arrange, move, and focus at will, your tmux now behaves like a true space editor. In episode 8 we step beyond a single screen: multi-session workflow — how to work with many sessions at once, move windows between sessions, and use the session list when one terminal is no longer enough. See you in episode 8!