Skip to content

Claude Code Interactive Mode

Claude Code's interactive mode provides rich keyboard shortcuts and operating methods, allowing you to efficiently interact with your AI assistant. This guide will detail all available interactive features.

📖 Official Documentation: Claude Code Interactive Mode | Complete Guide

Keyboard Shortcuts

General Controls

ShortcutDescriptionContext
Ctrl+CCancel current input or generationStandard interrupt
Ctrl+DExit Claude Code sessionEOF signal
Ctrl+LClear terminal screenPreserve conversation history
Up/Down arrowsNavigate command historyRecall previous inputs
Esc + EscEdit last messageDouble escape to modify

Multi-line Input

When you need to input multi-line content, you can use the following methods:

MethodShortcutContext
Quick escape\ + EnterWorks in all terminals
macOS defaultOption+EnterDefault on macOS
Terminal setupShift+EnterAfter /terminal-setup
Control sequenceCtrl+JMulti-line newline character
Paste modeDirect pasteFor code blocks, logs

Quick Commands

ShortcutDescriptionNotes
Starting #Memory shortcut - add to CLAUDE.mdPrompts file selection
Starting /Slash commandsSee Slash Commands

Vim Mode

Claude Code supports vim-style editing mode, providing familiar operations for vim users.

Enable Vim Mode

  • Temporary enable: Use /vim command
  • Permanent enable: Configure via /config

Mode Switching

CommandActionFrom Mode
EscEnter NORMAL modeINSERT
iInsert before cursorNORMAL
IInsert at line beginningNORMAL
aInsert after cursorNORMAL
AInsert at line endNORMAL
oOpen new line belowNORMAL
OOpen new line aboveNORMAL

Basic Movement

CommandAction
h/j/k/lMove left/down/up/right
wNext word
eEnd of word
bPrevious word

Line Navigation

CommandAction
0Line beginning
$Line end
^First non-whitespace character

Document Navigation

CommandAction
ggInput beginning
GInput end

Editing (NORMAL Mode)

Delete Operations

CommandAction
xDelete character
ddDelete line
DDelete to line end
dw/de/dbDelete word/to end/backward

Change Operations

CommandAction
ccChange line
CChange to line end
cw/ce/cbChange word/to end/backward
.Repeat last change

Command History

Claude Code provides powerful command history functionality to help you quickly reuse previous commands:

History Management

  • Storage method: History stored by working directory
  • Clear method: Use /clear command to clear
  • Navigation method: Use up/down arrow keys to navigate history
  • Search feature: Ctrl+R reverse search history (if terminal supports)

Notes

  • History expansion: ! commands are disabled by default to avoid accidental execution of history commands

Practical Tips

Efficient Input Tips

  1. Code Block Input

    • Directly paste code blocks, Claude Code will automatically detect and preserve formatting
    • Use \ + Enter to quickly add new lines
  2. Command Combinations

    • Combine slash commands with regular conversation
    • Use # prefixed messages to add to project memory
  3. History Reuse

    • Use arrow keys to quickly find previous commands
    • Esc + Esc to edit last message instead of retyping

Workflow Optimization

  1. Multi-line Editing

    # Use backslash continuation
    This is the first line \
    This is the second line \
    This is the third line
  2. Quick Memory Addition

    # This information will be added to CLAUDE.md
    Remember: This project uses TypeScript + React
  3. Command Chaining

    /model opus
    Please help me optimize this code's performance

Troubleshooting

Common Issues

Multi-line input not working?

  • Check if terminal supports corresponding shortcuts
  • Try using /terminal-setup to configure Shift+Enter
  • Use universal \ + Enter method

Vim mode won't enable?

  • Confirm using /vim command
  • Check configuration settings via /config
  • Restart Claude Code session

History search not working?

  • Confirm terminal supports Ctrl+R
  • Check terminal's key binding settings
  • Try using up/down arrow keys for manual navigation

By mastering these interactive mode features, you'll be able to use Claude Code more efficiently and improve your development efficiency and experience.