Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Selection PromptNew to Visual Studio Code? Get it now.
Selection Prompt

Selection Prompt

cnatom

|
1 install
| (0) | Free
Copy a concise prompt for the active VS Code selection, including file path, line range, and selected code.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Selection Prompt

中文

Selection Prompt 用于把 VS Code 当前选区复制成一段简洁 prompt,方便粘贴给 Codex CLI 或其他代码助手。

选中代码后按 Cmd+Shift+C,或执行命令 Selection Prompt: Copy。复制内容格式如下:

--- 代码片段开始 ---
- 文件: /absolute/path/to/file.dart
- 工作区相对路径: lib/example.dart
- 选区: L100-L102

```dart
selected code
```
--- 代码片段结束 ---

自定义模板

在 VS Code Settings 中修改:

{
  "selectionPrompt.startSeparator": "--- 代码片段开始 ---",
  "selectionPrompt.endSeparator": "--- 代码片段结束 ---",
  "selectionPrompt.template": "{{startSeparator}}\n- 文件: {{file}}\n- 工作区相对路径: {{relativePath}}\n- 选区: {{range}}\n\n{{fence}}{{language}}\n{{code}}\n{{fence}}\n{{endSeparator}}"
}

可用变量:{{startSeparator}}、{{endSeparator}}、{{file}}、{{relativePath}}、{{range}}、{{language}}、{{code}}、{{fence}}。

说明:

  • 安装后会自动绑定 macOS 快捷键 Cmd+Shift+C。
  • 如果快捷键被用户自定义快捷键占用,扩展启动时会提示你到 Keyboard Shortcuts 中调整。
  • 该扩展只读取当前编辑器选区,并把生成内容写入剪贴板。
  • 连续复制多个代码段时,每段都会带开始和结束分隔符,便于 AI 区分不同片段。

English

Selection Prompt copies the current VS Code selection as a concise prompt for Codex CLI or other coding assistants.

Select code and press Cmd+Shift+C, or run Selection Prompt: Copy.

Customize selectionPrompt.template, selectionPrompt.startSeparator, and selectionPrompt.endSeparator in VS Code Settings. Supported variables: {{startSeparator}}, {{endSeparator}}, {{file}}, {{relativePath}}, {{range}}, {{language}}, {{code}}, {{fence}}.

Notes:

  • The macOS shortcut Cmd+Shift+C is contributed automatically after installation.
  • If a user keybinding already uses this shortcut, the extension shows a warning on startup.
  • Each copied block includes start and end separators so multiple pasted snippets remain distinct.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft