Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Claude Code Control and Modes

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)


3. Command History

  1. Storage rules: stored independently per working directory,/clear commands can clear the current session's history
  2. Reverse search (Ctrl+R)
  3. After pressing, type a keyword to match historical commands and highlight them
  4. Repeat Ctrl+R Cycle through earlier matches
  5. Tab/Esc Accept the match and edit,Enter execute it directly,Ctrl+C cancel the search
  6. - After pressing, type a keyword to match historical commands and highlight them - Repeat `Ctrl+R` to cycle through earlier matches - `Tab/Esc` accepts the match and edits, `Enter` executes it directly, `Ctrl+C` cancels the search

    4. Background Bash Commands

    Supports running time-consuming commands asynchronously without blocking session operations.

    1. How to run
    2. Prompt Claude to run a command in the background
    3. When executing a command, press Ctrl+B(Tmux users press twice) to generate a unique task ID for tracking
    4. - Prompt Claude to run commands in the background - When executing a command, press `Ctrl+B` (Tmux users press twice) to generate a unique task ID for tracking
      1. Bash mode (! prefix)
      2. Input ! 命令 Can execute Bash commands directly (without Claude's intervention), example:! npm test
      3. Commands and their output count toward the session context, supporting Ctrl+B background execution, ideal for quickly running shell operations
      4. - Entering `! command` executes Bash commands directly (without Claude's intervention), e.g., `! npm test` - commands and their output count toward the session context, and support `Ctrl+B` for background execution, ideal for quickly running shell operations
        1. Applicable scenarios: long-running processes such as build tools, package managers, test runners, and development servers