Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Copy Path and Line
Copy Path and Line

Copy Path and Line

Nick Harrington

|
84 installs
| (1) | Free
Adds "Copy full path and line number" and "Copy relative path and line number" commands to the text editor context menu.
Download

A Visual Studio 2022/2026 extension that adds Copy full path and line number and Copy relative path and line number commands to the code editor right-click context menu.

What it does

Right-clicking in any open source file gives you two entries:

Copy full path and line number — copies the absolute file path and cursor line number: C:\Dev\MyProject\src\Foo.cs (Line: 42)

Copy relative path and line number — copies the path relative to the open solution directory: src\Foo.cs (Line: 42)

When text spanning multiple lines is selected, both commands capture the full range: src\Foo.cs (Lines: 42-58)

If no solution is open, the relative command falls back to the filename alone. Both commands are hidden for unsaved (untitled) files.

Keyboard shortcuts

Both commands can be bound to keyboard shortcuts via Tools → Options → Environment → Keyboard:

  • EditorContextMenus.CodeWindow.Copyfullpathandlinenumber

  • EditorContextMenus.CodeWindow.Copyrelativepathandlinenumber

    Configuration

    Open Tools → Options → Copy Path and Line → General to configure the extension.

    Setting Default Description
    Use Unix-style paths Off Use forward slashes instead of backslashes. (Always on when Markdown format is enabled)
    Use Markdown link format Off Output a Markdown link instead of plain text. (Automatically enables Unix-style paths)

Example output with Unix-style paths enabled:

C:/Dev/MyProject/src/Foo.cs (Line: 42)

src/Foo.cs (Lines: 42-58)

Example output with Markdown link format enabled:

Foo.cs (C:/Dev/MyProject/src/Foo.cs#L42)

Foo.cs (src/Foo.cs#L42-L58)

The Markdown anchor syntax (#L42, #L42-L58) is recognised by GitHub, GitLab, VS Code, and AI coding tools such as OpenAI Codex.

Supported versions

  • Visual Studio 2022 (17.x)
  • Visual Studio 2026 (18.x)

Changelog

[1.2.0] - 2026-05-08

Added

  • Markdown link format option (Tools → Options). When enabled, both commands produce [file.cs](path/to/file.cs#L42) — compatible with GitHub, GitLab, VS Code, and AI coding tools such as OpenAI Codex.

  • Multi-line selection support. When a selection spanning multiple lines is active, both commands capture the full range: file.cs (Lines: 42-58) in plain text, or [file.cs](path/to/file.cs#L42-L58) in Markdown mode.

Changed

  • Enabling Markdown link format automatically enables Unix-style paths, as backslashes are not valid in Markdown URLs.

[1.1.0] - 2025-03-16

Added

  • Unix-style paths option. When enabled, path separators are forward slashes (/) instead of backslashes (\).

[1.0.0]

Initial release.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft