Description
When running Claude Code CLI in a VS Code integrated terminal, the IDE selection context is passed automatically as a system reminder (e.g., "The user selected lines 76 to 82 from ..."). However, there's no way to explicitly insert multiple @file#L-L reference into the prompt text via a keyboard shortcut.
The VS Code extension supports Option+K to insert selection references, but users who prefer the CLI (for access to full slash commands, etc.) don't have an equivalent.
Proposed Solution
Add a new keybinding action (e.g., chat:insertSelection or chat:insertFileReference) that:
- Reads the current IDE selection context (file path + line range)
- Inserts an
@path/to/file#L76-82 reference into the prompt input at the cursor position
This would allow users to configure it in ~/.claude/keybindings.json:
{
"bindings": [
{
"context": "Chat",
"bindings": {
"option+k": "chat:insertSelection"
}
}
]
}
Motivation
The CLI has features not available in the VS Code extension panel. Users who prefer the CLI for its full feature set currently lose the convenience of explicitly referencing selected code via a shortcut. This bridges that gap.
Alternatives Considered
- Using the VS Code extension instead: Loses access to CLI-only features
- Manually typing
@file#L-L references: Works but is slow and error-prone
Description
When running Claude Code CLI in a VS Code integrated terminal, the IDE selection context is passed automatically as a system reminder (e.g., "The user selected lines 76 to 82 from ..."). However, there's no way to explicitly insert multiple
@file#L-Lreference into the prompt text via a keyboard shortcut.The VS Code extension supports
Option+Kto insert selection references, but users who prefer the CLI (for access to full slash commands, etc.) don't have an equivalent.Proposed Solution
Add a new keybinding action (e.g.,
chat:insertSelectionorchat:insertFileReference) that:@path/to/file#L76-82reference into the prompt input at the cursor positionThis would allow users to configure it in
~/.claude/keybindings.json:{ "bindings": [ { "context": "Chat", "bindings": { "option+k": "chat:insertSelection" } } ] }Motivation
The CLI has features not available in the VS Code extension panel. Users who prefer the CLI for its full feature set currently lose the convenience of explicitly referencing selected code via a shortcut. This bridges that gap.
Alternatives Considered
@file#L-Lreferences: Works but is slow and error-prone