Editor to CLI
Attach selected code to AI CLI tools like Claude directly from VS Code — via terminal injection or clipboard — without leaving your editor.
Repository: https://github.com/sureshdevaj/editor-to-cli
Features
- Attach selected code to AI CLI — one shortcut captures your selection with file and line context
- 3 path format modes — relative path, absolute path, or auto-detected GitHub permalink
- Terminal-first transport — inject the prompt directly into a named terminal (e.g. a running
claude session)
- Clipboard fallback — automatically falls back to clipboard when no matching terminal is found
- Configurable settings — control transport mode, path format, terminal name matching, and auto-enter behaviour
- No telemetry — zero data collection, no network calls, no tracking of any kind
Usage
- Open any source file in VS Code
- Select the code you want to send to your AI CLI
- Press
Cmd+Shift+. (Mac) or Ctrl+Shift+. (Windows / Linux)
The extension formats your selection as a file reference and delivers it to the configured destination.
Keyboard Shortcut
| Platform |
Shortcut |
| macOS |
Cmd + Shift + . |
| Windows / Linux |
Ctrl + Shift + . |
Only active when the editor is focused and text is selected.
Control how the file reference is formatted using editorToCli.pathFormat:
| Value |
Example output |
relative (default) |
src/transport.ts#L10-20 |
absolute |
/Users/you/project/src/transport.ts#L10-20 |
github |
https://github.com/user/repo/blob/main/src/transport.ts#L10-L20 |
GitHub permalink mode
When pathFormat is set to "github", the extension:
- Reads the
origin remote URL from your project's .git/config
- Reads the current branch from
.git/HEAD
- Builds a full GitHub permalink automatically
Supports both SSH (git@github.com:...) and HTTPS remote formats.
Falls back to relative path with a warning if git info cannot be detected.
Transport Modes
| Mode |
Behaviour |
auto (default) |
Looks for a terminal whose name contains terminalMatch. Injects if found, otherwise copies to clipboard. |
terminal |
Always injects into the currently active terminal. |
clipboard |
Always copies to clipboard — useful when your AI CLI runs outside VS Code. |
Configuration
Open Settings (Cmd+, / Ctrl+,) and search for Editor to CLI, or edit your settings.json directly:
{
"editorToCli.pathFormat": "relative",
"editorToCli.transport": "auto",
"editorToCli.terminalMatch": "claude",
"editorToCli.autoEnter": false
}
| Setting |
Type |
Default |
Description |
editorToCli.pathFormat |
"relative" | "absolute" | "github" |
"relative" |
Format of the file path in the output |
editorToCli.transport |
"auto" | "terminal" | "clipboard" |
"auto" |
How to deliver the prompt |
editorToCli.terminalMatch |
string |
"claude" |
Substring matched (case-insensitive) against terminal names in auto mode |
editorToCli.autoEnter |
boolean |
false |
Press Enter automatically after injecting into the terminal |
No Telemetry
This extension does not collect any usage data, does not make any network requests, and does not use any external dependencies. It uses only the VS Code API.
License
MIT