# tmux_window:select_layout/2

- **Package:** libtmux_erlang
- **Language:** Erlang
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-erlang/blob/d1b6308440cf9eb8f6647e7ae434bce60e849368/apps/libtmux_erlang/src/tmux_window.erl#L131
- **Page:** https://libtmux.org/en/erlang/latest/reference/tmux_window-select_layout-2/

```
select_layout(Window, Layout)
-spec select_layout(tmux_model:window(), layout()) ->
                       {ok, tmux_operation:completed()} |
                       {error, tmux_operation:failure()}.
```

Select a built-in arrangement or restore a literal serialized layout for this registered physical window. Binary names must exactly match one of the five built-ins; abbreviations and other names are rejected. Legacy serialized layouts need four hexadecimal checksum digits, a comma and nonempty data. This guard avoids a malformed-header crash in tmux 3.3 and 3.3a.

Native JSON v2 layouts require a bounded JSON object with V = 2 and an L
object. They return unsupported_capability on tmux before 3.8 without
dispatching a tmux command. This preserves `get/2` layout restoration on newer
servers.

Execution unzooms the window and changes it in every linked session. tmux
validates serialized geometry; malformed geometry can return a command error.
The layout argument uses no shell or format expansion. Existing rows are not
refreshed; use `get/2` or a fresh snapshot to observe layout and pane
geometry.

Unsupported atom names fail before dispatch:

## Examples

```erlang
1> tmux_window:select_layout(invalid_row, unknown_layout).
{error,#{code => invalid_layout,path => [layout]}}
```

## Parameters

- `Window` (`tmux_model:window()`)
- `Layout` (`layout()`)

## tmux command

The tmux commands behind `select_layout/2`.

- [`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) |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`window.Window.selectLayout`](/en/ts/latest/reference/window-window-selectlayout/) (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) |
| OCaml | [`Libtmux_unix.Client.select_layout`](/en/ocaml/latest/reference/libtmux_unix-client-select_layout/) (function) |
| Perl | [`LibTmux::Server::select_layout`](/en/perl/latest/reference/libtmux-server-select_layout/) (method). Explicit Server operation. Captured entities remain local observations; use a new snapshot to observe changes. |

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