Copy Path with LinesCopy absolute or relative file paths — with optional line numbers and selection ranges — straight to your clipboard. Ideal for referencing code locations in tickets, pull requests, chat, or documentation. CommandsFour commands are available from the right-click context menu inside the editor (under Copy Path with Lines) and from the Command Palette (
Output Format
The path separator matches your OS (backslash on Windows, forward slash on Linux/Mac). Line numbers are always 1-based. Linux / Mac examples
Windows examples
Usage
Working with Multiple SelectionsThe "with Lines" commands are aware of all active cursors and selections. Each selection becomes a token ( Multiple cursors →
|
| Shortcut | How |
|---|---|
Alt+Click / Option+Click |
Place an additional cursor anywhere |
Ctrl+D / Cmd+D |
Select next occurrence of the current word (adds a cursor per match) |
Ctrl+Alt+↑ / Cmd+Option+↑ |
Add cursor on the line above |
Ctrl+Alt+↓ / Cmd+Option+↓ |
Add cursor on the line below |
Each cursor is on a single line → each token is a single line number → result: :23,50
Multiple range selections → :10-15,23-30
| Shortcut | How |
|---|---|
Ctrl+D / Cmd+D (repeated) |
Each press selects the next occurrence as a full range |
Ctrl+Shift+L / Cmd+Shift+L |
Select all occurrences of the current word at once |
Each selection spans multiple lines → each token is a range → result: :10-15,23-30
Column / box selection → one token per row
| Shortcut | How |
|---|---|
Shift+Alt+drag / Shift+Option+drag |
Drag to create a rectangular multi-line selection |
Each row becomes a separate selection → each token is a single line → result: :10,11,12,13
Fallback Behavior
- No workspace open: "Copy Relative Path" commands automatically fall back to the absolute path.
- File outside the workspace root: same fallback — if the relative path would start with
../, the absolute path is used instead. - Unsaved (untitled) file: a warning is shown and nothing is copied.
Installation
From the Marketplace
Search for Copy Path with Lines in the VS Code Extensions panel (Ctrl+Shift+X / Cmd+Shift+X) and click Install.
From a .vsix file
code --install-extension copy-path-with-lines-0.1.0.vsix
License
MIT