# tmux.Pane.Swap

- **Module:** tmux.Pane
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-go/blob/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/window_pane_swap.go#L133
- **Page:** https://libtmux.org/reference/go/tmux-pane-swap/

```
tmux.Pane.Swap(ctx: context.Context, request: SwapPaneRequest) -> (PaneSwapResult, error)
```

Swap exchanges the receiver with one exact or adjacent pane. Explicit targets use exact linked-pane views; PaneID alone does not distinguish linked views. Unless Detach is set, tmux may change active-pane selection; this is not a global client-focus guarantee. A directional swap cannot identify the adjacent target because tmux does not report it, so the returned [PaneSwapResult].Target is zero.

An explicit swap returns freshly materialized exact views for both original
PaneIDs. If exact refresh fails after the command, Swap returns a predicted
result carrying every known identity with the error. Earlier failures return
zero; transport errors are delivery-ambiguous.
