Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Copy Path with Line NumberNew to Visual Studio Code? Get it now.
Copy Path with Line Number

Copy Path with Line Number

dagangshe

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

Copy Path with Line Number

Copy the current file path and cursor line or selected line range to the clipboard. For example, the command copies lib/viva_sim_core/src/sim_engine.cpp:132 or lib/viva_sim_core/src/sim_engine.cpp:132-140.

The extension runs in VS Code's local UI host, so it copies to the local clipboard when you work in a Remote SSH window.

Use

  1. Open a file and place the cursor on a line, or select a line range.
  2. Open the Command Palette with Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows and Linux.
  3. Run Copy File Path with Line Number.

When multiple disjoint selections are present, the first contiguous block in the file is used. Files inside a workspace use a path relative to their workspace folder. Files outside a workspace use their absolute path. The copied result is also shown in the status bar briefly.

Development

Open this folder in VS Code and press F5 to launch an Extension Development Host. In that window, open a file and run Copy File Path with Line Number from the Command Palette.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft