Back to Pi Mono

Keybindings

packages/coding-agent/docs/keybindings.md

0.84.011.5 KB
Original Source

Keybindings

All keyboard shortcuts can be customized via ~/.pi/agent/keybindings.json. Each action can be bound to one or more keys.

The config file uses the same namespaced keybinding ids that pi uses internally and that extension authors use in keyHint() and injected keybindings managers.

Older configs using pre-namespaced ids such as cursorUp or expandTools are migrated automatically to the namespaced ids on startup.

After editing keybindings.json, run /reload in pi to apply the changes without restarting the session.

Key Format

modifier+key where modifiers are ctrl, shift, alt (combinable) and keys are:

  • Letters: a-z
  • Digits: 0-9
  • Special: escape, esc, enter, return, tab, space, backspace, delete, insert, clear, home, end, pageUp, pageDown, up, down, left, right
  • Function: f1-f12
  • Symbols: `, -, =, [, ], \, ;, ', ,, ., /, !, @, #, $, %, ^, &, *, (, ), _, +, |, ~, {, }, :, <, >, ?

Modifier combinations: ctrl+shift+x, alt+ctrl+x, ctrl+shift+alt+x, ctrl+1, etc.

All Actions

TUI Editor Cursor Movement

Keybinding idDefaultDescription
tui.editor.cursorUpupMove cursor up, browsing older history at the top
tui.editor.cursorDowndownMove cursor down, browsing newer history at the bottom
tui.editor.historyPrevious(none)Select the previous prompt history entry
tui.editor.historyNext(none)Select the next prompt history entry
tui.editor.cursorLeftleft, ctrl+bMove cursor left
tui.editor.cursorRightright, ctrl+fMove cursor right
tui.editor.cursorWordLeftalt+left, ctrl+left, alt+bMove cursor word left
tui.editor.cursorWordRightalt+right, ctrl+right, alt+fMove cursor word right
tui.editor.cursorLineStarthome, ctrl+home, ctrl+aMove to line start
tui.editor.cursorLineEndend, ctrl+end, ctrl+eMove to line end
tui.editor.jumpForwardctrl+]Jump forward to character
tui.editor.jumpBackwardctrl+alt+]Jump backward to character
tui.editor.pageUppageUp, ctrl+pageUpScroll up by page
tui.editor.pageDownpageDown, ctrl+pageDownScroll down by page

The dedicated history actions always change history entries, regardless of the cursor position in a multiline prompt. Explicit history bindings take precedence over application actions while the main editor is focused, so binding tui.editor.historyPrevious to ctrl+p overrides model cycling in that context without changing Ctrl+P in selectors.

TUI Editor Deletion

Keybinding idDefaultDescription
tui.editor.deleteCharBackwardbackspaceDelete character backward
tui.editor.deleteCharForwarddelete, ctrl+dDelete character forward
tui.editor.deleteWordBackwardctrl+w, alt+backspaceDelete word backward
tui.editor.deleteWordForwardalt+d, alt+deleteDelete word forward
tui.editor.deleteToLineStartctrl+uDelete to line start
tui.editor.deleteToLineEndctrl+kDelete to line end

TUI Input

Keybinding idDefaultDescription
tui.input.newLineshift+enter, ctrl+jInsert new line
tui.input.submitenterSubmit input
tui.input.tabtabTab / autocomplete

TUI Kill Ring

Keybinding idDefaultDescription
tui.editor.yankctrl+yPaste most recently deleted text
tui.editor.yankPopalt+yCycle through deleted text after yank
tui.editor.undoctrl+-Undo last edit

TUI Clipboard and Selection

Keybinding idDefaultDescription
tui.input.copyctrl+cCopy selection
tui.select.upupMove selection up
tui.select.downdownMove selection down
tui.select.pageUppageUpPage up in list
tui.select.pageDownpageDownPage down in list
tui.select.confirmenterConfirm selection
tui.select.cancelescape, ctrl+cCancel selection

TUI Fullscreen Viewport

These actions apply when interactive mode uses --tui-mode fullscreen and target the primary transcript scroll region. Two-finger trackpad and mouse-wheel input scroll the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler. Dragging with the primary mouse button selects text and copies it to the clipboard; holding at the transcript's top or bottom edge auto-scrolls into off-screen content.

Fullscreen transcript bindings take precedence over editor bindings. The default unmodified navigation keys therefore control the transcript in fullscreen mode, while their ctrl variants continue to control the editor. Outside fullscreen mode, both variants control the editor.

KeyDefault modeFullscreen mode
home, endEditorTranscript
ctrl+home, ctrl+endEditorEditor
pageUp, pageDownEditorTranscript
ctrl+pageUp, ctrl+pageDownEditorEditor

This routing remains configurable through the ordinary action bindings. For example, "tui.altScreen.pageUp": "ctrl+pageUp" makes pageUp control the editor and ctrl+pageUp control the transcript in fullscreen mode. Setting "tui.altScreen.pageUp": [] disables that transcript shortcut entirely. User bindings replace the defaults for that action.

Keybinding idDefaultDescription
tui.altScreen.pageUppageUpScroll the transcript up by one page
tui.altScreen.pageDownpageDownScroll the transcript down by one page
tui.altScreen.previousPromptctrl+shift+upJump to the previous marked message
tui.altScreen.nextPromptctrl+shift+downJump to the next marked message
tui.altScreen.tophomeScroll to the beginning of the transcript
tui.altScreen.bottomendScroll to the transcript end and follow new output

Application

Keybinding idDefaultDescription
app.interruptescapeCancel / abort
app.clearctrl+cClear editor
app.exitctrl+dExit (when editor empty)
app.suspendctrl+z (none on Windows)Suspend to background
app.editor.externalctrl+gOpen in external editor (externalEditor, $VISUAL, $EDITOR, Notepad on Windows, or nano elsewhere)
app.clipboard.pasteImagectrl+v (alt+v on Windows)Paste image from clipboard

Sessions

Keybinding idDefaultDescription
app.session.new(none)Start a new session (/new)
app.session.tree(none)Open session tree navigator (/tree)
app.session.fork(none)Fork current session (/fork)
app.session.resume(none)Open session resume picker (/resume)
app.session.togglePathctrl+pToggle path display
app.session.toggleSortctrl+sToggle sort mode
app.session.toggleNamedFilterctrl+nToggle named-only filter
app.session.renamectrl+rRename session
app.session.deletectrl+dDelete session
app.session.deleteNoninvasivectrl+backspaceDelete session when query is empty

Models and Thinking

Keybinding idDefaultDescription
app.model.selectctrl+lOpen model selector
app.model.cycleForwardctrl+pCycle to next model
app.model.cycleBackwardshift+ctrl+pCycle to previous model
app.thinking.cycleshift+tabCycle thinking level
app.thinking.togglectrl+tCollapse or expand thinking blocks

Display and Message Queue

Keybinding idDefaultDescription
app.tools.expandctrl+oCollapse or expand tool output
app.message.copyctrl+xCopy the last assistant message, or the selected message in /tree
app.message.followUpalt+enterQueue follow-up message
app.message.dequeuealt+upRestore queued messages to editor

Tree Navigation

Keybinding idDefaultDescription
app.tree.foldOrUpctrl+left, alt+leftFold current branch segment, or jump to the previous segment start
app.tree.unfoldOrDownctrl+right, alt+rightUnfold current branch segment, or jump to the next segment start or branch end
app.tree.editLabelshift+lEdit the label on the selected tree node
app.tree.toggleLabelTimestampshift+tToggle label timestamps in the tree
app.tree.filter.defaultctrl+dSet tree filter to default view
app.tree.filter.noToolsctrl+tToggle tree filter that hides tool results
app.tree.filter.userOnlyctrl+uToggle tree filter that shows only user messages
app.tree.filter.labeledOnlyctrl+lToggle tree filter that shows only labeled entries
app.tree.filter.allctrl+aToggle tree filter that shows all entries
app.tree.filter.cycleForwardctrl+oCycle tree filter forward
app.tree.filter.cycleBackwardshift+ctrl+oCycle tree filter backward

Scoped Models Selector

Used inside the scoped models selector (opened via /scoped-models).

Keybinding idDefaultDescription
app.models.savectrl+sSave current model selection to settings
app.models.enableAllctrl+aEnable all models (or all matching the current search)
app.models.clearAllctrl+xClear all models (or all matching the current search)
app.models.toggleProviderctrl+pToggle all models for the current provider
app.models.reorderUpalt+upMove the selected model up in the cycle order
app.models.reorderDownalt+downMove the selected model down in the cycle order

Custom Configuration

Create ~/.pi/agent/keybindings.json:

json
{
  "tui.editor.historyPrevious": "ctrl+p",
  "tui.editor.historyNext": "ctrl+n",
  "tui.editor.deleteWordBackward": ["ctrl+w", "alt+backspace"]
}

Each action can have a single key or an array of keys. User config overrides defaults.

On native Windows, app.suspend has no default binding because Windows terminals do not support Unix job control. If you bind it manually, pi shows a status message instead of suspending. In WSL, the normal Linux ctrl+z/fg behavior still applies.

Emacs Example

json
{
  "tui.editor.historyPrevious": "ctrl+p",
  "tui.editor.historyNext": "ctrl+n",
  "tui.editor.cursorLeft": ["left", "ctrl+b"],
  "tui.editor.cursorRight": ["right", "ctrl+f"],
  "tui.editor.cursorWordLeft": ["alt+left", "alt+b"],
  "tui.editor.cursorWordRight": ["alt+right", "alt+f"],
  "tui.editor.deleteCharForward": ["delete", "ctrl+d"],
  "tui.editor.deleteCharBackward": ["backspace", "ctrl+h"],
  "tui.input.newLine": ["shift+enter", "ctrl+j"]
}

Vim Example

json
{
  "tui.editor.cursorUp": ["up", "alt+k"],
  "tui.editor.cursorDown": ["down", "alt+j"],
  "tui.editor.cursorLeft": ["left", "alt+h"],
  "tui.editor.cursorRight": ["right", "alt+l"],
  "tui.editor.cursorWordLeft": ["alt+left", "alt+b"],
  "tui.editor.cursorWordRight": ["alt+right", "alt+w"]
}