# window.Window.format

- **Module:** window.Window
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/window.rs#L728
- **Page:** https://libtmux.org/reference/rs/window-window-format/

```
window.Window.format(self, template: &str) -> Result<TmuxText, Error>
```

Expand a tmux format string in this window's context.

This returns `display-message` output instead of showing it in front of
a person with [`Self::display`]. See [`crate::Server::format`] for the
shell boundary around command and recursive formats.

# Errors

Returns an error when tmux cannot be reached or refuses the format.

## Example

```rust
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("shown").await?;
let window = session.active_window().await?.expect("a window");

let expanded = window.format("#{window_id}").await?;
assert_eq!(expanded.to_string_lossy(), window.id().to_string());

guard.shutdown().await?;
```
