Copy the active file as an @path:lines reference, ready to paste into AI chats (Claude, Copilot Chat, Cursor, etc.).
VS Code's built-in Copy Relative Path does not add the @ prefix or selection line numbers, and keybindings/tasks can't build the string (no variable for the selection end). This tiny extension does it.
Usage
- Run Copy AI Reference (@path:lines) from the Command Palette, the editor context menu, or the keybinding.
- Default keybinding:
Cmd+Alt+R(macOS) /Ctrl+Alt+R(Windows/Linux).
Output
| Situation | Result |
|---|---|
| No selection | @src/neco.txt |
| Multi-line selection | @src/neco.txt:8-15 |
| Single-line selection | @src/neco.txt:8 |
Paths always use forward slashes (Windows-safe). A selection that overflows onto the start of the next line is not counted as an extra line.
Install locally (no build)
Copy this folder to ~/.vscode/extensions/copy-ai-ref/ and run Developer: Reload Window. VS Code loads it on startup — no vsce or compilation needed.
Publish to the Marketplace
-
Set a real
publisherinpackage.json(create one at https://marketplace.visualstudio.com/manage). -
Add an
icon.png(128x128). -
Package and publish:
npx @vscode/vsce package # builds copy-ai-ref-0.0.1.vsix npx @vscode/vsce publish # needs a Personal Access Token
License
MIT