Skip to main content

Keyboard shortcuts

Keyboard shortcuts may vary by platform and terminal. Press ? to see available shortcuts for your environment.macOS users: Option/Alt key shortcuts (Alt+B, Alt+F, Alt+Y, Alt+M, Alt+P) require configuring Option as Meta in your terminal:
  • iTerm2: Settings → Profiles → Keys → Set Left/Right Option key to “Esc+”
  • Terminal.app: Settings → Profiles → Keyboard → Check “Use Option as Meta Key”
  • VS Code: Settings → Profiles → Keys → Set Left/Right Option key to “Esc+”
See Terminal configuration for details.

General controls

ShortcutDescriptionContext
Ctrl+CCancel current input or generationStandard interrupt
Ctrl+DExit Claude Code sessionEOF signal
Ctrl+LClear terminal screenKeeps conversation history
Ctrl+OToggle verbose outputShows detailed tool usage and execution
Ctrl+RReverse search command historySearch through previous commands interactively
Ctrl+V or Cmd+V (iTerm2) or Alt+V (Windows)Paste image from clipboardPastes an image or path to an image file
Ctrl+BBackground running tasksBackgrounds bash commands and agents. Tmux users press twice
Left/Right arrowsCycle through dialog tabsNavigate between tabs in permission dialogs and menus
Up/Down arrowsNavigate command historyRecall previous inputs
Esc + EscRewind the code/conversationRestore the code and/or conversation to a previous point
Shift+Tab or Alt+M (some configurations)Toggle permission modesSwitch between Auto-Accept Mode, Plan Mode, and normal mode
Option+P (macOS) or Alt+P (Windows/Linux)Switch modelSwitch models without clearing your prompt
Option+T (macOS) or Alt+T (Windows/Linux)Toggle extended thinkingEnable or disable extended thinking mode. Run /terminal-setup first to enable this shortcut

Text editing

ShortcutDescriptionContext
Ctrl+KDelete to end of lineStores deleted text for pasting
Ctrl+UDelete entire lineStores deleted text for pasting
Ctrl+YPaste deleted textPaste text deleted with Ctrl+K or Ctrl+U
Alt+Y (after Ctrl+Y)Cycle paste historyAfter pasting, cycle through previously deleted text. Requires Option as Meta on macOS
Alt+BMove cursor back one wordWord navigation. Requires Option as Meta on macOS
Alt+FMove cursor forward one wordWord navigation. Requires Option as Meta on macOS

Theme and display

ShortcutDescriptionContext
Ctrl+TToggle syntax highlighting for code blocksOnly works inside the /theme picker menu. Controls whether code in Claude’s responses uses syntax coloring
Syntax highlighting is only available in the native build of Claude Code.

Multiline input

MethodShortcutContext
Quick escape\ + EnterWorks in all terminals
macOS defaultOption+EnterDefault on macOS
Shift+EnterShift+EnterWorks out of the box in iTerm2, WezTerm, Ghostty, Kitty
Control sequenceCtrl+JLine feed character for multiline
Paste modePaste directlyFor code blocks, logs
Shift+Enter works without configuration in iTerm2, WezTerm, Ghostty, and Kitty. For other terminals (VS Code, Alacritty, Zed, Warp), run /terminal-setup to install the binding.

Quick commands

ShortcutDescriptionNotes
/ at startSlash commandSee slash commands
! at startBash modeRun commands directly and add execution output to the session
@File path mentionTrigger file path autocomplete

Vim editor mode

Enable vim-style editing with /vim command or configure permanently via /config.

Mode switching

CommandActionFrom mode
EscEnter NORMAL modeINSERT
iInsert before cursorNORMAL
IInsert at beginning of lineNORMAL
aInsert after cursorNORMAL
AInsert at end of lineNORMAL
oOpen line belowNORMAL
OOpen line aboveNORMAL
CommandAction
h/j/k/lMove left/down/up/right
wNext word
eEnd of word
bPrevious word
0Beginning of line
$End of line
^First non-blank character
ggBeginning of input
GEnd of input
f{char}Jump to next occurrence of character
F{char}Jump to previous occurrence of character
t{char}Jump to just before next occurrence of character
T{char}Jump to just after previous occurrence of character
;Repeat last f/F/t/T motion
,Repeat last f/F/t/T motion in reverse

Editing (NORMAL mode)

CommandAction
xDelete character
ddDelete line
DDelete to end of line
dw/de/dbDelete word/to end/back
ccChange line
CChange to end of line
cw/ce/cbChange word/to end/back
yy/YYank (copy) line
yw/ye/ybYank word/to end/back
pPaste after cursor
PPaste before cursor
>>Indent line
<<Dedent line
JJoin lines
.Repeat last change

Text objects (NORMAL mode)

Text objects work with operators like d, c, and y:
CommandAction
iw/awInner/around word
iW/aWInner/around WORD (whitespace-delimited)
i"/a"Inner/around double quotes
i'/a'Inner/around single quotes
i(/a(Inner/around parentheses
i[/a[Inner/around brackets
i{/a{Inner/around braces

Command history

Claude Code maintains command history for the current session:
  • History is stored per working directory
  • Cleared with /clear command
  • Use Up/Down arrows to navigate (see keyboard shortcuts above)
  • Note: History expansion (!) is disabled by default

Reverse search with Ctrl+R

Press Ctrl+R to interactively search through your command history:
  1. Start search: Press Ctrl+R to activate reverse history search
  2. Type query: Enter text to search for in previous commands - the search term will be highlighted in matching results
  3. Navigate matches: Press Ctrl+R again to cycle through older matches
  4. Accept match:
    • Press Tab or Esc to accept the current match and continue editing
    • Press Enter to accept and execute the command immediately
  5. Cancel search:
    • Press Ctrl+C to cancel and restore your original input
    • Press Backspace on empty search to cancel
The search displays matching commands with the search term highlighted, making it easy to find and reuse previous inputs.

Background bash commands

Claude Code supports running bash commands in the background, allowing you to continue working while long-running processes execute.

How backgrounding works

When Claude Code runs a command in the background, it runs the command asynchronously and immediately returns a background task ID. Claude Code can respond to new prompts while the command continues executing in the background. To run commands in the background, you can either:
  • Prompt Claude Code to run a command in the background
  • Press Ctrl+B to move a regular Bash tool invocation to the background. (Tmux users must press Ctrl+B twice due to tmux’s prefix key.)
Key features:
  • Output is buffered and Claude can retrieve it using the BashOutput tool
  • Background tasks have unique IDs for tracking and output retrieval
  • Background tasks are automatically cleaned up when Claude Code exits
To disable all background task functionality, set the CLAUDE_CODE_DISABLE_BACKGROUND_TASKS environment variable to 1. See Environment variables for details. Common backgrounded commands:
  • Build tools (webpack, vite, make)
  • Package managers (npm, yarn, pnpm)
  • Test runners (jest, pytest)
  • Development servers
  • Long-running processes (docker, terraform)

Bash mode with ! prefix

Run bash commands directly without going through Claude by prefixing your input with !:
! npm test
! git status
! ls -la
Bash mode:
  • Adds the command and its output to the conversation context
  • Shows real-time progress and output
  • Supports the same Ctrl+B backgrounding for long-running commands
  • Does not require Claude to interpret or approve the command
This is useful for quick shell operations while maintaining conversation context.

See also

⌂ Proxy