What’s Covered in This OpenCode Cheat Sheet (August 2026)

This page is for OpenCode (opencode.ai) — the open-source AI coding agent TUI — not OpenAI Codex and not VS Code. Defaults below match the official tui.json keybinds: leader Ctrl+X, command list Ctrl+P, interrupt Esc, plus slash commands (/new, /sessions, /models, /undo). Use in-page search for a hotkey or command name. Bindings merge in tui.json; set a key to none to disable it.

How the OpenCode leader key works

Press Ctrl+X, release it, then press the action key. Example: Ctrl+X then N starts a new session. Holding both keys at once does nothing — that is the usual reason “OpenCode shortcuts don’t work.” leader_timeout defaults to 2000 ms. Subagent navigation is an exception: Up is parent, Left/Right cycle children, Ctrl+X then Down jumps to the first child.

Leader key & command palette

Leader key (press, release, then the next key)
CtrlX
Command palette / command list (Ctrl+P)
CtrlP
Toggle which-key overlay
CtrlAltK
Exit OpenCode
CtrlC
Exit OpenCode (EOF)
CtrlD
Exit OpenCode (leader)
CtrlXthenQ
Suspend terminal process
CtrlZ

Sessions

New session (Ctrl+X then N)
CtrlXthenN
Session list / resume / continue
CtrlXthenL
Compact / summarize session
CtrlXthenC
Interrupt current turn
Esc
Rename session
CtrlR
Delete session (in session list)
CtrlD
Export session to Markdown
CtrlXthenX
Session timeline
CtrlXthenG
Status view
CtrlXthenS
Toggle sidebar
CtrlXthenB
Theme list
CtrlXthenT
Open prompt in $EDITOR
CtrlXthenE

Subagent session navigation

Go to parent session
Cycle to next child session
Cycle to previous child session
Jump to first child session
CtrlXthen

Models, agents & variants

Model list
CtrlXthenM
Model provider list
CtrlA
Toggle model favorite
CtrlF
Cycle recent models
F2
Cycle recent models (reverse)
ShiftF2
Agent list
CtrlXthenA
Cycle agent
Tab
Cycle agent (reverse)
ShiftTab
Cycle variant
CtrlT

Messages & transcript

Copy last message
CtrlXthenY
Undo last message (git repo)
CtrlXthenU
Redo undone message
CtrlXthenR
Toggle conceal / tips overlay
CtrlXthenH
Messages page up
PageUp
Messages page down
PageDown
Messages page up (alternate)
CtrlAltB
Messages page down (alternate)
CtrlAltF
Scroll messages one line up
CtrlAltY
Scroll messages one line down
CtrlAltE
Half-page up
CtrlAltU
Half-page down
CtrlAltD
Jump to first message
CtrlG
Jump to last message
CtrlAltG

Prompt input, @ files & bash

Submit prompt
Enter
Insert newline (Shift+Enter)
ShiftEnter
Insert newline (alternate)
CtrlEnter
Insert newline (Ctrl+J)
CtrlJ
Paste
CtrlV
Clear input
CtrlC
Previous prompt in history
Next prompt in history
Attach file with fuzzy search
@
Run a local bash command
!
Open slash-command menu
/
Complete autocomplete suggestion
Tab
Hide autocomplete
Esc
Autocomplete previous item
CtrlP
Autocomplete next item
CtrlN

Prompt editing (Readline)

Start of line
CtrlA
End of line
CtrlE
Move left / right
CtrlB
Move right (alternate)
CtrlF
Word backward
AltB
Word forward
AltF
Delete to start of line
CtrlU
Delete to end of line
CtrlK
Delete previous word
CtrlW
Delete next word
AltD
Delete character
CtrlD
Delete whole line
CtrlShiftD
Undo in prompt
Ctrl-
Redo in prompt
Ctrl.
Select all (Super / Win key)
WinA
Permission prompt fullscreen
CtrlF

Slash commands

Show help
/help
New session (alias /clear)
/new
List / switch sessions (aliases /resume, /continue)
/sessions
Compact session (alias /summarize)
/compact
List models
/models
Connect a provider / API key
/connect
Open external editor
/editor
Export conversation to Markdown
/export
Undo last message and file changes
/undo
Redo after /undo
/redo
Share current session
/share
Unshare session
/unshare
Theme list
/themes
Toggle thinking / reasoning blocks
/thinking
Toggle tool-execution details
/details
Create or update AGENTS.md
/init
Exit (aliases /quit, /q)
/exit

Desktop app — prompt editing

Start of current line
CtrlA
End of current line
CtrlE
Back one character
CtrlB
Forward one character
CtrlF
Back one word
AltB
Forward one word
AltF
Delete character under cursor
CtrlD
Kill to end of line
CtrlK
Kill to start of line
CtrlU
Kill previous word
CtrlW
Kill next word
AltD
Transpose characters
CtrlT
Cancel popovers / abort running response
CtrlG

Leader key & command palette

Leader key (press, release, then the next key) — not Cmd+X
CtrlX
Command palette / command list (Ctrl+P)
CtrlP
Toggle which-key overlay
CtrlK
Exit OpenCode
CtrlC
Exit OpenCode (EOF)
CtrlD
Exit OpenCode (leader)
CtrlXthenQ
Suspend terminal process
CtrlZ

Sessions

New session (Ctrl+X then N)
CtrlXthenN
Session list / resume / continue
CtrlXthenL
Compact / summarize session
CtrlXthenC
Interrupt current turn
Esc
Rename session
CtrlR
Delete session (in session list)
CtrlD
Export session to Markdown
CtrlXthenX
Session timeline
CtrlXthenG
Status view
CtrlXthenS
Toggle sidebar
CtrlXthenB
Theme list
CtrlXthenT
Open prompt in $EDITOR
CtrlXthenE

Subagent session navigation

Go to parent session
Cycle to next child session
Cycle to previous child session
Jump to first child session
CtrlXthen

Models, agents & variants

Model list
CtrlXthenM
Model provider list
CtrlA
Toggle model favorite
CtrlF
Cycle recent models
F2
Cycle recent models (reverse)
F2
Agent list
CtrlXthenA
Cycle agent
Tab
Cycle agent (reverse)
Tab
Cycle variant
CtrlT

Messages & transcript

Copy last message
CtrlXthenY
Undo last message (git repo)
CtrlXthenU
Redo undone message
CtrlXthenR
Toggle conceal / tips overlay
CtrlXthenH
Messages page up
PageUp
Messages page down
PageDown
Messages page up (alternate)
CtrlB
Messages page down (alternate)
CtrlF
Scroll messages one line up
CtrlY
Scroll messages one line down
CtrlE
Half-page up
CtrlU
Half-page down
CtrlD
Jump to first message
CtrlG
Jump to last message
CtrlG

Prompt input, @ files & bash

Submit prompt
Return
Insert newline (Shift+Return)
Return
Insert newline (alternate)
CtrlReturn
Insert newline (Ctrl+J)
CtrlJ
Insert newline (Option+Return)
Return
Paste
CtrlV
Clear input
CtrlC
Previous prompt in history
Next prompt in history
Attach file with fuzzy search
@
Run a local bash command
!
Open slash-command menu
/
Complete autocomplete suggestion
Tab
Hide autocomplete
Esc
Autocomplete previous item
CtrlP
Autocomplete next item
CtrlN

Prompt editing (Readline)

Start of line
CtrlA
End of line
CtrlE
Move left / right
CtrlB
Move right (alternate)
CtrlF
Word backward
B
Word forward
F
Delete to start of line
CtrlU
Delete to end of line
CtrlK
Delete previous word
CtrlW
Delete next word
D
Delete character
CtrlD
Delete whole line
CtrlD
Undo in prompt
Z
Undo in prompt (alternate)
Ctrl-
Redo in prompt
Z
Select all
A
Permission prompt fullscreen
CtrlF

Slash commands

Show help
/help
New session (alias /clear)
/new
List / switch sessions (aliases /resume, /continue)
/sessions
Compact session (alias /summarize)
/compact
List models
/models
Connect a provider / API key
/connect
Open external editor
/editor
Export conversation to Markdown
/export
Undo last message and file changes
/undo
Redo after /undo
/redo
Share current session
/share
Unshare session
/unshare
Theme list
/themes
Toggle thinking / reasoning blocks
/thinking
Toggle tool-execution details
/details
Create or update AGENTS.md
/init
Exit (aliases /quit, /q)
/exit

Desktop app — prompt editing

Start of current line (Emacs-style, not Cmd+A)
CtrlA
End of current line
CtrlE
Back one character
CtrlB
Forward one character
CtrlF
Back one word
B
Forward one word
F
Delete character under cursor
CtrlD
Kill to end of line
CtrlK
Kill to start of line
CtrlU
Kill previous word
CtrlW
Kill next word
D
Transpose characters
CtrlT
Cancel popovers / abort running response
CtrlG

Customize OpenCode keybinds in tui.json

Put overrides in tui.json (or tui.jsonc). They merge with defaults. This file is separate from opencode.json. Disable a shortcut with "none". Point OpenCode at another path with OPENCODE_TUI_CONFIG.

{
  "$schema": "https://opencode.ai/tui.json",
  "leader_timeout": 2000,
  "keybinds": {
    "leader": "ctrl+x",
    "session_new": "<leader>n",
    "command_list": "ctrl+p",
    "session_compact": "none"
  }
}

If Shift+Enter still submits instead of inserting a newline, use Ghostty or Warp, or bind Shift+Enter in Windows Terminal to send \u001b[13;2u. Full terminal notes: OpenCode keybinds docs.

Also see: Claude CodeCodexGhosttyCursorGitHub CopilotAntigravity

OpenCode Shortcuts — Frequently Asked Questions

What is the OpenCode leader key and how do I use it?

The default OpenCode leader key is Ctrl+X. Press and release Ctrl+X, then press the action key. Example: Ctrl+X then N starts a new session. The TUI greys out the input while it waits (default 2000 ms, set leader_timeout in tui.json). Do not hold Ctrl+X and the next key together.

How do I change OpenCode keyboard shortcuts or keybinds?

Edit keybinds in tui.json (schema https://opencode.ai/tui.json). Only override the keys you want to change — they merge with defaults. Set a binding to none or false to disable it. Use <leader> in values so they follow your leader key. Runtime settings also live in the command palette (Ctrl+P). This is separate from opencode.json.

How do I start a new session or open the command palette in OpenCode?

New session: Ctrl+X then N, or type /new (alias /clear). Command palette: Ctrl+P. Session list: Ctrl+X then L, or /sessions. Interrupt the current turn with Esc.

Why doesn’t Shift+Enter insert a newline in OpenCode?

OpenCode maps newlines to Shift+Enter, Ctrl+Enter, Alt+Enter, and Ctrl+J. Many terminals swallow Shift+Enter. Ghostty and Warp usually work. In Windows Terminal, bind Shift+Enter to send the CSI u sequence \u001b[13;2u. You can also type /editor (Ctrl+X then E) to compose in $EDITOR.

Are OpenCode shortcuts the same on Windows, Linux, and macOS?

The TUI uses Ctrl+X as the leader on every platform — it is not Cmd+X on Mac. Alt bindings become Option on macOS. Super mappings (select all, undo, redo) use Cmd. Desktop prompt editing is Emacs-style Ctrl+A / Ctrl+E even on Mac, and is not configurable in opencode.json.

Is OpenCode the same as OpenAI Codex?

No. OpenCode (opencode.ai) is an open-source AI coding TUI with a Ctrl+X leader key and tui.json keybinds. OpenAI Codex is a separate CLI and ChatGPT desktop workspace. Use this page for OpenCode; use the Codex shortcuts page for OpenAI Codex.