Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>CopyRefNew to Visual Studio Code? Get it now.
CopyRef

CopyRef

Sarisia

|
3 installs
| (0) | Free
Copy the workspace-relative file path with line number(s) to the clipboard.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

vscode-copyref

Copies the workspace-relative file path with the current line number(s) to the clipboard.

Works best with coding agents!

image

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.copyReference command).

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)

  1. Clone the repo and install dependencies:
    git clone https://github.com/sarisia/vscode-copyref
    cd vscode-copyref
    npm install
    
  2. Open the folder in VS Code.
  3. Press F5 — VS Code builds the extension and opens a new Extension Development Host window with the extension loaded.
  4. 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
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft