Files
LLeMbas-TTY/docs/config/lua/keyassignment/SendString.md
T
Wez Furlong 0f8146b212 docs: shift from return {} style to config.something style
Nudge new users towards using this style:

```lua
local config = {}
config.color_scheme = 'Batman'
return config
```

and surface how to write lua modules closer to the main section
on config files. In that lua modules section, nudge towards using
a convention similar to that of the plugin spec described in
this commit: e4ae8a844d
2023-03-19 18:26:21 -07:00

1014 B

SendString

Sends the string specified argument to the terminal in the current tab, as though that text were literally typed into the terminal.

config.keys = {
  { key = 'm', mods = 'CMD', action = wezterm.action.SendString 'Hello' },
}

You can also emit escape sequences using SendString. This example shows how to bind Alt-LeftArrow/RightArrow to the Alt-b/f, an emacs style keybinding for moving backwards/forwards through a word in a line editor.

\x1b is the ESC character:

local act = wezterm.action

config.keys = {
  -- Make Option-Left equivalent to Alt-b which many line editors interpret as backward-word
  { key = 'LeftArrow', mods = 'OPT', action = act.SendString '\x1bb' },
  -- Make Option-Right equivalent to Alt-f; forward-word
  { key = 'RightArrow', mods = 'OPT', action = act.SendString '\x1bf' },
}

See also SendKey which makes the example above much more convenient, and Multiple for combining multiple actions in a single press.