# libtmux:swap-panes

- **Package:** libtmux
- **Language:** Common Lisp
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-lisp/blob/c2e5fc4ed3befda21f45dfa5d5868c38fd138311/src/placement.lisp#L154
- **Public owner:** libtmux
- **Page:** https://libtmux.org/en/lisp/latest/reference/libtmux-swap-panes/

```
(swap-panes client first-pane second-pane &key (detached t) preserve-zoom (observe t) cancel-token timeout output-limit)
```

Swap two physical panes; return an outcome with replacements in a fresh vector.
The vector follows argument order. DETACHED defaults true; tmux still adjusts
active-pane references when panes change windows. PRESERVE-ZOOM restores zoom.
Signals STALE-TARGET or an operational condition. Earlier captures stay local
and unchanged; observation failure is retained separately.

## Parameters

- `client`
- `first-pane`
- `second-pane`
- `detached?`
- `preserve-zoom?`
- `observe?`
- `cancel-token?`
- `timeout?`
- `output-limit?`

## 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)

## Guides

Pages that discuss `swap-panes`.

- [Explicit operations](/en/lisp/latest/guides/operations/)
