# format_replace

- **Language:** C
- **Kind:** function
- **Source:** https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5055
- **Page:** https://libtmux.org/en/tmux/latest/reference/c-function-format-c-format_replace/

```c
static int format_replace(struct format_expand_state *, const char *, size_t, char **, size_t *, size_t *)
```

## Parameters

- `es` (`struct format_expand_state *`)
- `key` (`const char *`)
- `keylen` (`size_t`)
- `buf` (`char **`)
- `len` (`size_t *`)
- `off` (`size_t *`)

## Called by

- [`format_expand1`](/en/tmux/latest/reference/c-function-format-c-format_expand1/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5727)

## Calls

- [`colour_fromstring`](/en/tmux/latest/reference/c-function-colour_fromstring/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5302)
- [`format_bool_op_1`](/en/tmux/latest/reference/c-function-format-c-format_bool_op_1/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5373)
- [`format_bool_op_n`](/en/tmux/latest/reference/c-function-format-c-format_bool_op_n/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5379)
- [`format_build_modifiers`](/en/tmux/latest/reference/c-function-format-c-format_build_modifiers/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5083)
- [`format_check_time`](/en/tmux/latest/reference/c-function-format-c-format_check_time/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5359)
- [`format_choose`](/en/tmux/latest/reference/c-function-format-c-format_choose/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5349)
- [`format_expand1`](/en/tmux/latest/reference/c-function-format-c-format_expand1/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5289)
- [`format_find`](/en/tmux/latest/reference/c-function-format-c-format_find/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5448)
- [`format_free_modifiers`](/en/tmux/latest/reference/c-function-format-c-format_free_modifiers/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5613)
- [`format_logging`](/en/tmux/latest/reference/c-function-format-c-format_logging/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5086)
- [`format_loop_clients`](/en/tmux/latest/reference/c-function-format-c-format_loop_clients/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5325)
- [`format_loop_panes`](/en/tmux/latest/reference/c-function-format-c-format_loop_panes/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5321)
- [`format_loop_sessions`](/en/tmux/latest/reference/c-function-format-c-format_loop_sessions/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5313)
- [`format_loop_windows`](/en/tmux/latest/reference/c-function-format-c-format_loop_windows/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5317)
- [`format_match`](/en/tmux/latest/reference/c-function-format-c-format_match/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5423)
- [`format_replace_expression`](/en/tmux/latest/reference/c-function-format-c-format_replace_expression/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5504)
- [`format_search`](/en/tmux/latest/reference/c-function-format-c-format_search/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5344)
- [`format_session_name`](/en/tmux/latest/reference/c-function-format-c-format_session_name/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5333)
- [`format_skip1`](/en/tmux/latest/reference/c-function-format-c-format_skip1/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5436)
- [`format_strip`](/en/tmux/latest/reference/c-function-format-c-format_strip/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5165)
- [`format_sub`](/en/tmux/latest/reference/c-function-format-c-format_sub/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5540)
- [`format_trim_left`](/en/tmux/latest/reference/c-function-format_trim_left/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5550)
- [`format_trim_right`](/en/tmux/latest/reference/c-function-format_trim_right/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5561)
- [`format_true`](/en/tmux/latest/reference/c-function-format_true/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5472)
- [`format_unescape`](/en/tmux/latest/reference/c-function-format-c-format_unescape/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5283)
- [`format_window_name`](/en/tmux/latest/reference/c-function-format-c-format_window_name/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5329)
- [`strtonum`](/en/tmux/latest/reference/c-function-strtonum/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5290)
- [`utf8_padcstr`](/en/tmux/latest/reference/c-function-utf8_padcstr/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5575)
- [`utf8_rpadcstr`](/en/tmux/latest/reference/c-function-utf8_rpadcstr/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5580)
- [`xasprintf`](/en/tmux/latest/reference/c-function-xasprintf/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5294)
- [`xreallocarray`](/en/tmux/latest/reference/c-function-xreallocarray/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5109)
- [`xstrdup`](/en/tmux/latest/reference/c-function-xstrdup/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5292)
- [`xstrndup`](/en/tmux/latest/reference/c-function-xstrndup/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L5080)

## Other function references

- [`colour_force_rgb`](/en/tmux/latest/reference/c-function-colour_force_rgb/) (function)
- [`format_copy_state`](/en/tmux/latest/reference/c-function-format-c-format_copy_state/) (function)
- [`format_width`](/en/tmux/latest/reference/c-function-format_width/) (function)

## Referenced declarations

- [`FORMAT_BASENAME`](/en/tmux/latest/reference/c-define-format-c-format_basename/) (constant)
- [`FORMAT_CHARACTER`](/en/tmux/latest/reference/c-define-format-c-format_character/) (constant)
- [`FORMAT_CLIENTS`](/en/tmux/latest/reference/c-define-format-c-format_clients/) (constant)
- [`FORMAT_COLOUR`](/en/tmux/latest/reference/c-define-format-c-format_colour/) (constant)
- [`FORMAT_DIRNAME`](/en/tmux/latest/reference/c-define-format-c-format_dirname/) (constant)
- [`FORMAT_EXPAND`](/en/tmux/latest/reference/c-define-format-c-format_expand/) (constant)
- [`format_expand_state`](/en/tmux/latest/reference/c-struct-format_expand_state/) (struct)
- [`FORMAT_EXPAND_TIME`](/en/tmux/latest/reference/c-define-format-c-format_expand_time/) (constant)
- [`FORMAT_EXPANDTIME`](/en/tmux/latest/reference/c-define-format-c-format_expandtime/) (constant)
- [`FORMAT_LENGTH`](/en/tmux/latest/reference/c-define-format-c-format_length/) (constant)
- [`FORMAT_LITERAL`](/en/tmux/latest/reference/c-define-format-c-format_literal/) (constant)
- [`format_log`](/en/tmux/latest/reference/c-define-format-c-format_log/) (constant)
- [`FORMAT_MAX_REPEAT`](/en/tmux/latest/reference/c-define-format-c-format_max_repeat/) (constant)
- [`FORMAT_MAX_WIDTH`](/en/tmux/latest/reference/c-define-format-c-format_max_width/) (constant)
- [`FORMAT_NOT`](/en/tmux/latest/reference/c-define-format-c-format_not/) (constant)
- [`FORMAT_NOT_NOT`](/en/tmux/latest/reference/c-define-format-c-format_not_not/) (constant)
- [`FORMAT_PANES`](/en/tmux/latest/reference/c-define-format-c-format_panes/) (constant)
- [`FORMAT_PRETTY`](/en/tmux/latest/reference/c-define-format-c-format_pretty/) (constant)
- [`FORMAT_QUOTE_ARGUMENTS`](/en/tmux/latest/reference/c-define-format-c-format_quote_arguments/) (constant)
- [`FORMAT_QUOTE_SHELL`](/en/tmux/latest/reference/c-define-format-c-format_quote_shell/) (constant)
- [`FORMAT_QUOTE_STYLE`](/en/tmux/latest/reference/c-define-format-c-format_quote_style/) (constant)
- [`FORMAT_REPEAT`](/en/tmux/latest/reference/c-define-format-c-format_repeat/) (constant)
- [`FORMAT_SESSION_NAME`](/en/tmux/latest/reference/c-define-format-c-format_session_name/) (constant)
- [`FORMAT_SESSIONS`](/en/tmux/latest/reference/c-define-format-c-format_sessions/) (constant)
- [`FORMAT_TIMESTRING`](/en/tmux/latest/reference/c-define-format-c-format_timestring/) (constant)
- [`FORMAT_WIDTH`](/en/tmux/latest/reference/c-define-format-c-format_width/) (constant)
- [`FORMAT_WINDOW_NAME`](/en/tmux/latest/reference/c-define-format-c-format_window_name/) (constant)
- [`FORMAT_WINDOWS`](/en/tmux/latest/reference/c-define-format-c-format_windows/) (constant)
- [`format_expand_state.ft`](/en/tmux/latest/reference/c-struct-format_expand_state-ft/) (attribute)
- [`window_pane.id`](/en/tmux/latest/reference/c-struct-window_pane-id/) (attribute)
- [`format_modifier.modifier`](/en/tmux/latest/reference/c-struct-format_modifier-modifier/) (attribute)
- [`sort_criteria.order`](/en/tmux/latest/reference/c-struct-sort_criteria-order/) (attribute)
- [`sort_criteria.reversed`](/en/tmux/latest/reference/c-struct-sort_criteria-reversed/) (attribute)
- [`SORT_ACTIVITY`](/en/tmux/latest/reference/c-enum-sort_order-sort_activity/) (constant)
- [`SORT_CREATION`](/en/tmux/latest/reference/c-enum-sort_order-sort_creation/) (constant)
- [`sort_crit`](/en/tmux/latest/reference/c-variable-format-c-sort_crit/) (attribute)
- [`SORT_INDEX`](/en/tmux/latest/reference/c-enum-sort_order-sort_index/) (constant)
- [`SORT_NAME`](/en/tmux/latest/reference/c-enum-sort_order-sort_name/) (constant)
- [`SORT_ORDER`](/en/tmux/latest/reference/c-enum-sort_order-sort_order/) (constant)
- [`format_tree.wp`](/en/tmux/latest/reference/c-struct-format_tree-wp/) (attribute)
