Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Copy path to codeNew to Visual Studio Code? Get it now.
Copy path to code

Copy path to code

Cem Onan

|
1 install
| (0) | Free
Copy the active file's absolute path (and selected line range, if any) to the clipboard.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Copy path to code

Demo

Copies the active file's path (with optional line range) to the clipboard in @<path>[#L<range>] format — ready to paste into AI chats and code reviews.

VS Code Marketplace Version Installs GitHub Release CI VS Code Engine

Install

From the VS Code Marketplace (recommended)

Extensions → search Copy path to code → Install.

Or visit marketplace.visualstudio.com.

From the GitHub releases

  1. Go to Releases
  2. Download the latest .vsix file
  3. In VS Code or Cursor: Extensions → ... → Install from VSIX... → select the .vsix

Assign a keyboard shortcut

Ctrl+K Ctrl+S → search Copy path to code → set your preferred shortcut. The command ID is copy-path-to-code.copyPathToCode.

From source

npm install
npm run package
# → copy-path-to-code-<version>.vsix

Then install the .vsix as above.

Usage

Open the command palette (Ctrl+Shift+P / Cmd+Shift+P) and run Copy path to code.

Editor state Clipboard output
Active file, no selection @/absolute/path/to/file.ts
Single line selected @/absolute/path/to/file.ts#L12
Multiple lines selected @/absolute/path/to/file.ts#L12-L18
Multi-cursor each cursor rendered with its line, sorted top-to-bottom, joined with ,
No active file / unsaved buffer error notification — clipboard is left unchanged

Lines are 1-indexed. Paths use native separators (\ on Windows, / on macOS/Linux).

Development

npm run watch            # esbuild watch mode
                         # F5 → launch Extension Development Host
npm run test:unit        # vitest unit tests
npm run test:integration # Extension Host tests
npm test                 # all tests
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft