# Libtmux_unix.Client.swap_panes

- **Module:** Libtmux_unix
- **Package:** libtmux-unix
- **Language:** OCaml
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-ocaml/blob/205dfda49742592b479247049d186956e4a4cfe9/unix/libtmux_unix.mli#L713
- **Public owner:** Libtmux_unix
- **Page:** https://libtmux.org/en/ocaml/latest/reference/libtmux_unix-client-swap_panes/

```
val swap_panes :
  ?cancel:Cancellation.t ->
  t ->
  Libtmux.Pane.target ->
  Libtmux.Pane.target -> (unit, Libtmux.Error.t) result
```

Exchange pane positions without exchanging their identities or running processes. Both targets must belong to the same bound generation.

## Parameters

- `cancel?` (`Cancellation.t`)
- `arg1` (`t`)
- `arg2` (`Libtmux.Pane.target`)
- `arg3` (`Libtmux.Pane.target`)

## tmux command

The tmux commands behind `swap_panes`.

- [`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)

## 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) |
| Erlang | [`tmux_pane:swap/3`](/en/erlang/latest/reference/tmux_pane-swap-3/) (function) |
| 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 |
| 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#.
