# tmux_pane:swap/3

- **Package:** libtmux_erlang
- **Language:** Erlang
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-erlang/blob/d1b6308440cf9eb8f6647e7ae434bce60e849368/apps/libtmux_erlang/src/tmux_pane.erl#L258
- **Page:** https://libtmux.org/en/erlang/latest/reference/tmux_pane-swap-3/

```
swap(Source, Destination, Options)
-spec swap(tmux_model:pane(),
           tmux_model:pane(),
           swap_options()) ->
              {ok, tmux_operation:completed()} |
              {error, map()}.
```

Exchange two panes' layout positions within or across physical windows. Preserves their IDs and processes; parent windows, dimensions, indexes and inherited options can change. Both rows require the same registered owner. detach defaults true; active positions can still receive different panes. zoom maps to native -Z. Identical IDs do not exchange panes, but native zoom handling still runs; the default can unzoom even a same-pane swap. Returns the command result; `get/2` observes the resulting values explicitly.

## Parameters

- `Source` (`tmux_model:pane()`)
- `Destination` (`tmux_model:pane()`)
- `Options` (`swap_options()`)

## tmux command

The tmux commands behind `swap/3`.

- [`swap-pane`](/en/tmux/latest/manual/swap-pane/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_swap_pane_entry`](/en/tmux/latest/reference/c-variable-cmd_swap_pane_entry/) (attribute)
- [`cmd_swap_pane_exec`](/en/tmux/latest/reference/c-function-cmd-swap-pane-c-cmd_swap_pane_exec/) (function)

## Guides

Pages that discuss `swap/3`.

- [Native API documentation](/en/erlang/latest/guides/api-documentation/)
- [Isolate and rejoin a running pane](/en/erlang/latest/guides/panes/)

## In other ports

Exchange two panes

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Pane.swap`](/en/py/latest/reference/libtmux-pane-swap/) (method) |
| Ruby | [`LibTmux::Pane#swap`](/en/ruby/latest/reference/libtmux-pane-swap/) (method) |
| Lua | [`libtmux.Pane:swap`](/en/lua/latest/reference/libtmux-pane-swap/) (method) |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`pane.Pane.swapWith`](/en/ts/latest/reference/pane-pane-swapwith/) (method) |
| Rust | [`pane.Pane.swap_with`](/en/rs/latest/reference/pane-pane-swap_with/) (method) |
| Go | [`tmux.Pane.Swap`](/en/go/latest/reference/tmux-pane-swap/) (method) |
| Java | [`io.github.libtmux.Pane.swapWith`](/en/java/latest/reference/io-github-libtmux-pane-pane-swapwith/) (method) |
| C# | [`LibTmux.Pane.SwapAsync`](/en/csharp/latest/reference/libtmux-pane-swapasync/) (method) |
| C++ | [`libtmux::Pane::swap_with`](/en/cxx/latest/reference/libtmux-pane-swap_with/) (method) |
| Swift | `Server.swap(_:with:)` swaps windows, not panes |
| OCaml | [`Libtmux_unix.Client.swap_panes`](/en/ocaml/latest/reference/libtmux_unix-client-swap_panes/) (function) |
| Perl | No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands. |

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