# window.Window.selectLayout

- **Module:** window
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/window.ts#L522
- **Page:** https://libtmux.org/en/ts/latest/reference/window-window-selectlayout/

```
selectLayout(layout: string): Promise<void>
```

Apply a named or custom layout.

Names accept unique abbreviations. Checksums and tree structure are checked
before dispatch; tmux remains responsible for geometry and pruning.
This API limits custom layouts to 8192 characters and 256 nested groups.

Applying any layout while a pane is zoomed unzooms the window first —
tmux's own behavior, not this method's.

A [`window_layout`](/en/tmux/latest/catalog/formats/window_layout/) saved earlier and passed back here is not guaranteed
to put every pane back where it was. The classic layout string restores
the arrangement's shape but can rotate which pane lands in which
position. A JSON layout needs tmux 3.8 and restores exactly, provided the
reader receives JSON (see [`Server.connect`](/en/ts/latest/reference/server-server-connect/)).

Only a preset name, a layout string that parses here, or JSON on tmux
3.8+ is accepted: anything else is refused rather than sent, because two
ranges of tmux exit on a layout they cannot read and take every session
on the socket with them. tmux 3.3 and 3.3a die on a value with no
readable checksum, and 3.7 through 3.7d on one whose checksum is correct
and whose cells are not — so the checksum alone is not evidence, and the
layout is parsed in full before dispatch.

## Examples

```ts
await window.selectLayout("even-horizontal");
```

## Parameters

- `layout` (`string`)

## Raises

- [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError): when the layout name or serialized tree is invalid.
- [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError): when `layout` is ambiguous, or is neither a preset nor a layout string this package can parse.
- [`VersionTooLowError`](/en/ts/latest/reference/errors-versiontoolowerror/): when `layout` names a mirrored preset or JSON layout the running tmux is too old to apply.

## tmux command

The tmux commands behind `selectLayout`.

- [`select-layout`](/en/tmux/latest/manual/select-layout/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_select_layout_entry`](/en/tmux/latest/reference/c-variable-cmd_select_layout_entry/) (attribute)
- [`cmd_select_layout_exec`](/en/tmux/latest/reference/c-function-cmd-select-layout-c-cmd_select_layout_exec/) (function)

## In other ports

Set a window's pane layout

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Window.select_layout`](/en/py/latest/reference/libtmux-window-select_layout/) (method) |
| Ruby | [`LibTmux::Window#select_layout`](/en/ruby/latest/reference/libtmux-window-select_layout/) (method) |
| Lua | [`libtmux.Window:layout`](/en/lua/latest/reference/libtmux-window-layout/) (method) |
| Rust | [`window.Window.select_layout`](/en/rs/latest/reference/window-window-select_layout/) (method) |
| Go | [`tmux.Window.SelectLayout`](/en/go/latest/reference/tmux-window-selectlayout/) (method) |
| Java | [`io.github.libtmux.Window.selectLayout`](/en/java/latest/reference/io-github-libtmux-window-window-selectlayout/) (method) |
| C# | [`LibTmux.Window.SelectLayoutAsync`](/en/csharp/latest/reference/libtmux-window-selectlayoutasync/) (method) |
| C++ | [`libtmux::Window::select_layout`](/en/cxx/latest/reference/libtmux-window-select_layout/) (method) |
| Swift | [`Server.selectLayout(_:_:)`](/en/swift/latest/reference/server-selectlayout(_-_-)/) (method) |

No equivalent is recorded in PowerShell, Julia, Elixir, Kotlin, Scala or F#.
