Claude Code Control and Modes
The core capabilities of Claude Code's interactive mode includeKeyboard shortcuts、Vim editing mode、Command history managementandBackground Bash command execution; the following is the distilled key content:
I. Keyboard Shortcuts
Shortcut effects vary by terminal and system; macOS users need to configure the Option key as Meta (see the original text for configuration paths for different terminals); press ? to view the shortcuts available in the current environment.
| Classification | Shortcut/Action | Core Features |
|---|---|---|
| General controls | Ctrl+C |
Cancel current input/generation |
Ctrl+D |
Exit the session | |
Ctrl+L |
Clear the screen (keep history) | |
Ctrl+O |
Toggle verbose output (show tool execution logs) | |
Ctrl+R |
Reverse-search command history | |
Option+P/Alt+P |
Switch the model (without clearing the prompt) | |
| Text Editing | Ctrl+K/Ctrl+U |
Delete to end of line / delete the whole line (deleted content can be pasted) |
Ctrl+Y |
Paste Ctrl+K/Ctrl+U Deleted content |
|
Alt+B/Alt+F |
Move the cursor forward/backward by word (requires Meta key configuration) | |
| Theme display | Ctrl+T |
Toggle syntax highlighting for code blocks (only valid /theme within the menu) |
| Multi-line input | \+Enter / Shift+Enter` |
Newline input (Shift+Enter requires no configuration in terminals such as iTerm2/WezTerm) |
Ctrl+J |
Multi-line newline | |
| Quick commands | / |
Trigger a slash command (see the slash command documentation for details) |
! |
Run a Bash command directly (output counts toward the session) | |
@ |
Trigger file path autocompletion |
II. Vim Editor Mode
Pass /vim Enable temporarily with , or /config configure permanently with , supporting Vim's core operation logic.
1. Mode Switching
| Command | Operation | Trigger scenario |
|---|---|---|
Esc |
Enter NORMAL mode | In INSERT mode |
i/I |
Insert before the cursor / at the beginning of the line | In NORMAL mode |
a/A |
Insert after the cursor / at the end of the line | In NORMAL mode |
o/O |
Open a new line below/above | In NORMAL mode |
2. Core Operations (NORMAL Mode)
- navigation:
h/j/k/lMove up, down, left, right;w/e/bJump by word;gg/GJump to the beginning/end of input - Editing:
ddDelete line;yyCopy line;p/PPaste after/before the cursor;>>/<<Indent/Outdent - Text objects: used with
d/c/y, e.g.di"delete content inside double quotes,awselect the whole word
3. Command History
- Storage rules: stored independently per working directory,
/clearcommands can clear the current session's history - Reverse search (Ctrl+R)
Ctrl+R Cycle through earlier matchesTab/Esc Accept the match and edit,Enter execute it directly,Ctrl+C cancel the search4. Background Bash Commands
Supports running time-consuming commands asynchronously without blocking session operations.
- How to run
Ctrl+B(Tmux users press twice) to generate a unique task ID for tracking- Bash mode (! prefix)
! 命令 Can execute Bash commands directly (without Claude's intervention), example:! npm testCtrl+B background execution, ideal for quickly running shell operations- Applicable scenarios: long-running processes such as build tools, package managers, test runners, and development servers