Copies the workspace-relative file path with the current line number(s) to the clipboard.
Works best with coding agents!

How to invoke
- Right-click line number: Right-click any line number in the gutter → Copy Reference. If the clicked line is inside an active multi-line selection the full selection range is used; otherwise just that line is used.
- Right-click text: Editor text area context menu → Copy Reference
- Keyboard: Default:
Cmd+Shift+C(macOS) /Ctrl+Shift+C(Linux/Windows). Can be customized in Keyboard Shortcuts (copyref.copyReferencecommand).
Usage
| Action | Result |
|---|---|
Caret on line 10 of src/foo.ts |
src/foo.ts:10 |
Select lines 10–20 of src/foo.ts |
src/foo.ts:10-20 |
Development
Try in dev mode (Extension Development Host)
- Clone the repo and install dependencies:
git clone https://github.com/sarisia/vscode-copyref cd vscode-copyref npm install - Open the folder in VS Code.
- Press F5 — VS Code builds the extension and opens a new Extension Development Host window with the extension loaded.
- In that window, open any file, make a selection, and try the keybinding or right-click menu.
Build manually
npm run build # one-shot bundle to dist/
npm run watch # rebuild on every file save
npm run compile # type-check only (no output)
Package as .vsix
npm run package # produces vscode-copyref-<version>.vsix
Install locally with:
code --install-extension vscode-copyref-<version>.vsix