Select code, press Ctrl+Shift+C, and the reference (e.g. @src/foo.ts:10-20) is instantly pasted into your AI chat input — no manual copy-paste needed.
Works with VS Code and Cursor.
- Copy reference: Copies
@relative/path:lineor@relative/path:start-endto clipboard - Auto-focus & paste: After copy, automatically focuses and pastes into the target AI chat panel
- Target options: Claude Code, VS Code built-in Chat, or clipboard-only (
none) - No selection: When nothing is selected, copies the current line reference
- Shortcut:
Ctrl+Shift+C(Mac:Cmd+Shift+C) - Context menu: Right-click in editor → Copy/Paste section
- Select a code block, or place cursor on a line
- Press
Ctrl+Shift+C - The reference is copied and pasted into the configured AI chat input
Note: Claude Code may auto-convert
@file:lineto@file#line. Both formats point to the same lines.
Search copyCodeLineForAI in VS Code/Cursor settings:
| Setting | Type | Default | Description |
|---|---|---|---|
copyCodeLineForAI.autoFocusTarget |
string | "claudeCode" |
Target to auto-focus after copy: claudeCode (Claude Code), vscodeChat (VS Code built-in Chat), none (clipboard only) |
copyCodeLineForAI.prefix |
string | "@" |
Prefix character, e.g. @ or # |
copyCodeLineForAI.pathLineSeparator |
string | ":" |
Separator between path and line number |
copyCodeLineForAI.lineRangeSeparator |
string | "-" |
Separator between start and end line |
{
"copyCodeLineForAI.autoFocusTarget": "claudeCode",
"copyCodeLineForAI.prefix": "@",
"copyCodeLineForAI.pathLineSeparator": ":",
"copyCodeLineForAI.lineRangeSeparator": "-"
}- Default:
@src/foo.ts:10-20 - Single line (no selection):
@src/foo.ts:10 - Use
#as separator:@src/foo.ts#10-20
npm install -g @vscode/vsce
vsce package
# Then: Extensions view → Install from VSIXPress F5 to launch the Extension Development Host for debugging.
MIT License. See LICENSE for details.
选中代码,按 Ctrl+Shift+C,引用(如 @src/foo.ts:10-20)立即粘贴到 AI 对话输入框,无需手动复制粘贴。
适用于 VS Code 与 Cursor。
- 复制引用:将
@相对路径:行号或@相对路径:起始-结束复制到剪贴板 - 自动聚焦并粘贴:复制后自动聚焦并粘贴到目标 AI 对话面板
- 目标可选:Claude Code、VS Code 内置 Chat,或仅复制到剪贴板(
none) - 无选区:未选中时自动复制当前行引用
- 快捷键:
Ctrl+Shift+C(Mac:Cmd+Shift+C) - 右键菜单:编辑器右键 → 复制/粘贴区域
- 选中代码块(或将光标停在某行)
- 按
Ctrl+Shift+C - 引用已复制并粘贴到已配置的 AI 对话输入框
提示: Claude Code 可能自动将
@文件:行号转换为@文件#行号,两种格式指向同一段代码。
在 VS Code/Cursor 设置中搜索 copyCodeLineForAI:
| 设置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
copyCodeLineForAI.autoFocusTarget |
string | "claudeCode" |
复制后自动聚焦的目标:claudeCode(Claude Code)、vscodeChat(VS Code 内置 Chat)、none(仅复制到剪贴板) |
copyCodeLineForAI.prefix |
string | "@" |
路径前缀字符,如 @ 或 # |
copyCodeLineForAI.pathLineSeparator |
string | ":" |
路径与行号之间的分隔符 |
copyCodeLineForAI.lineRangeSeparator |
string | "-" |
行号范围分隔符 |
npm install -g @vscode/vsce
vsce package
# 在扩展视图选择「从 VSIX 安装」按 F5 启动调试。
MIT License. 详见 LICENSE。