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, Codex 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. Note: Codex target defaults to paste mode. SetcopyCodeLineForAI.codexUseAddToThreadtotrueto use Codex's officialAdd to Codex Threadbehavior.
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), codex (Codex chat), none (clipboard only) |
copyCodeLineForAI.codexUseAddToThread |
boolean | false |
Use Codex's official Add to Thread command instead of the default paste behavior. |
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.focusDelayMs |
number | 80 |
Delay in milliseconds before focusing or pasting into the target panel. |
{
"copyCodeLineForAI.autoFocusTarget": "claudeCode",
"copyCodeLineForAI.codexUseAddToThread": false,
"copyCodeLineForAI.prefix": "@",
"copyCodeLineForAI.pathLineSeparator": ":",
"copyCodeLineForAI.lineRangeSeparator": "-",
"copyCodeLineForAI.focusDelayMs": 80
}- Default:
@src/foo.ts:10-20 - Codex paste mode on Windows:
@src\foo.ts:10-20 - Single line (no selection):
@src/foo.ts:10 - Use
#as separator:@src/foo.ts#10-20
MIT License. See LICENSE for details.
选中代码,按 Ctrl+Shift+C,引用(如 @src/foo.ts:10-20)立即粘贴到 AI 对话输入框,无需手动复制粘贴。
适用于 VS Code 与 Cursor。
- 复制引用:将
@相对路径:行号或@相对路径:起始-结束复制到剪贴板 - 自动聚焦并粘贴:复制后自动聚焦并粘贴到目标 AI 对话面板
- 目标可选:Claude Code、VS Code 内置 Chat、Codex Chat,或仅复制到剪贴板(
none) - 无选区:未选中时自动复制当前行引用
- 快捷键:
Ctrl+Shift+C(Mac:Cmd+Shift+C) - 右键菜单:编辑器右键 → 复制/粘贴区域
- 选中代码块(或将光标停在某行)
- 按
Ctrl+Shift+C - 引用已复制并粘贴到已配置的 AI 对话输入框
提示: Claude Code 可能自动将
@文件:行号转换为@文件#行号,两种格式指向同一段代码。 提示: Codex 目标默认使用粘贴模式。可以将copyCodeLineForAI.codexUseAddToThread设为true,使用 Codex 官方的Add to Codex Thread行为。
在 VS Code/Cursor 设置中搜索 copyCodeLineForAI:
| 设置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
copyCodeLineForAI.autoFocusTarget |
string | "claudeCode" |
复制后自动聚焦的目标:claudeCode(Claude Code)、vscodeChat(VS Code 内置 Chat)、codex(Codex Chat)、none(仅复制到剪贴板) |
copyCodeLineForAI.codexUseAddToThread |
boolean | false |
使用 Codex 官方 Add to Thread 命令,而不是默认粘贴行为。 |
copyCodeLineForAI.prefix |
string | "@" |
路径前缀字符,如 @ 或 # |
copyCodeLineForAI.pathLineSeparator |
string | ":" |
路径与行号之间的分隔符 |
copyCodeLineForAI.lineRangeSeparator |
string | "-" |
行号范围分隔符 |
copyCodeLineForAI.focusDelayMs |
number | 80 |
聚焦或粘贴到目标面板前的延迟时间,单位毫秒。 |
MIT License. 详见 LICENSE。