Files
tty7/docs/customization/keybindings.mdx
T
l0ng-ai eaca1e50d8 fix(keymap): refuse a tmux prefix that cannot carry a sequence
Every preset binding is built as `<prefix> <key>`, and nothing checked the
prefix. `"prefix": ""` in a hand-edited config therefore produced no
sequence at all — it bound bare `c`, `x`, `z`, `n`, `o` and the digits
directly onto NewTab, CloseActiveTab, ToggleMaximizePane and the rest, so
typing an `x` in the terminal closed the tab. `"c"` and `"shift-c"` are
the same trap one step removed: the letter starts a sequence and swallows
the next keystroke, and shift-c is simply how a capital C is typed.

`preset_prefix` now requires one chord carrying a non-shift modifier and
falls back to the default otherwise, naming the refused prefix in the log.
That also catches `"C-a"` — tmux's own spelling, which gpui does not parse
— which previously slipped through to `action_bindings` and dismantled the
preset one binding at a time, warning about each key rather than about the
prefix that caused it.

The GUI only ever offered Ctrl-B and Ctrl-A, so this is reachable through
config.json, which the docs describe. Those docs also promised a **Prefix**
field to type into; it is a two-option row, and now says so.
2026-08-16 17:01:50 +08:00

99 lines
3.6 KiB
Plaintext

---
title: "Keybindings"
description: "Rebinding anything, chord sequences, and the tmux preset."
---
**Settings → Keybindings** (<kbd>⌘ ,</kbd>) lists every shortcut in the app,
grouped the same way the command palette is. The search box at the top of
Settings reaches this page too: type what a feature is called — `split`,
`commit`, `sftp` — and the page narrows to the shortcuts for it. Action names
work as well as labels, so a binding you read about in `keybindings.json` is
one search away from the row that sets it.
## Rebinding
Click a shortcut and press the new keys. It saves after a brief pause.
| | |
|---|---|
| Press keys | Set the binding |
| Press more keys | Chain a sequence — <kbd>⌃ B</kbd> then <kbd>X</kbd> |
| <kbd>Esc</kbd> | Cancel |
| <kbd>⌫</kbd> | Remove the last key — or, pressed first, reset the shortcut to its default |
**Restore all defaults** at the bottom undoes every rebinding at once. There is
no undo for that one.
<Frame caption="Placeholder — screenshot: the Keybindings page mid-capture, showing “Press keys…”">
<img src="/images/placeholder.svg" alt="Rebinding a shortcut" />
</Frame>
## Actions with no default key
Some actions ship deliberately unbound, because there is no obvious key left to
take: pane resize and swap, workspace selection, most git commands, SFTP, and
the panel tabs. They are all in the command palette, and all bindable here.
## Editing `config.json` instead
```json
{
"keybindings": {
"SplitRight": "cmd-d",
"ResizePaneLeft": "ctrl-alt-left",
"ToggleSftp": "cmd-shift-u"
}
}
```
The syntax is modifiers joined by `-`, then the key. Chords are separated by a
space.
| Token | Means |
|---|---|
| `secondary` | <kbd>⌘</kbd> on macOS, <kbd>Ctrl</kbd> elsewhere |
| `cmd` · `ctrl` · `alt` · `shift` | Literal modifiers |
| `ctrl-b n` | A two-key sequence |
An unknown action name or an invalid keystroke is skipped with a warning in the
log rather than breaking the rest of your bindings.
The full action list is on the [keyboard shortcuts](/reference/keyboard-shortcuts)
page.
## The tmux preset
**Settings → Keybindings → Preset → tmux** remaps pane and tab actions onto a
prefix — <kbd>⌃ B</kbd> by default, switchable to <kbd>⌃ A</kbd> on the
**Prefix** row beside it.
| | |
|---|---|
| <kbd>⌃ B</kbd> <kbd>C</kbd> · <kbd>X</kbd> | New tab · close tab |
| <kbd>⌃ B</kbd> <kbd>%</kbd> · <kbd>"</kbd> | Split right · split down |
| <kbd>⌃ B</kbd> <kbd>←→↑↓</kbd> | Move focus |
| <kbd>⌃ B</kbd> <kbd>⌃ ←→↑↓</kbd> | Resize the pane |
| <kbd>⌃ B</kbd> <kbd>O</kbd> · <kbd>;</kbd> | Next pane · previous pane |
| <kbd>⌃ B</kbd> <kbd>&#123;</kbd> · <kbd>&#125;</kbd> | Swap with the previous · next pane |
| <kbd>⌃ B</kbd> <kbd>Z</kbd> | Zoom the pane |
| <kbd>⌃ B</kbd> <kbd>N</kbd> · <kbd>P</kbd> | Next tab · previous tab |
| <kbd>⌃ B</kbd> <kbd>1</kbd>…<kbd>9</kbd> | Jump to a tab |
Two details that make it livable:
- A **bare prefix** reaches the shell after about a second, so <kbd>⌃ B</kbd>
still works as "back one character" when you meant it.
- **Prefix plus an unbound key** is passed straight through to the terminal, so
a tmux binding you did not remap still lands in whatever is running.
## Some non-obvious defaults
| | |
|---|---|
| <kbd>⇧ ⏎</kbd> · <kbd>⌥ ⏎</kbd> | Insert a newline at the prompt instead of submitting (`InsertNewline`) |
| <kbd>⌘ ⇧ ⏎</kbd> | Zoom the focused pane |
| <kbd>⌘ ⇧ E</kbd> | Toggle the code panel |
| <kbd>⌘ ⇧ R</kbd> | Restart the SSH session in this pane |
| <kbd>⌘ ⇧ O</kbd> | Workspace switcher |
| <kbd>⌘ ⇧ N</kbd> | New workspace |