# tmux.Window.Swap

- **Module:** tmux.Window
- **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#L79
- **Page:** https://libtmux.org/reference/go/tmux-window-swap/

```
tmux.Window.Swap(ctx: context.Context, request: SwapWindowRequest) -> (WindowSwapResult, error)
```

Swap exchanges the receiver and Target exact winlinks. Their stable WindowIDs move to the opposite session-and-index views; a WindowID alone does not identify either endpoint. Unless Detach is set, tmux may change the affected sessions' current-window selection; this is not a global client-focus guarantee.

Swap returns both freshly materialized exact endpoint views. If exact
refresh fails after the command, it returns a predicted [WindowSwapResult]
carrying both stable IDs and post-swap session/index contexts with the
error. Earlier failures return zero; transport errors are delivery-ambiguous.
