Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>R3BL Copy Selection Path and RangeNew to Visual Studio Code? Get it now.
R3BL Copy Selection Path and Range

R3BL Copy Selection Path and Range

R3BL

|
371 installs
| (1) | Free
Copy file path with selection ranges in Claude Code format (@path#L<start>-<end>) or IDE format (path:<line>) for single/no selection
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

R3BL Copy Selection Path and Range

Quickly copy file paths with selected line ranges in formats optimized for Claude Code and IDE navigation. Perfect for sharing code references in prompts, documentation, or team communication.

Features

  • Claude Code Format: Multi-line selections use @path#L<start>-<end> format
  • IDE Format: Single-line selections use path:<line> format for IDE compatibility
  • Keyboard Shortcuts: Quick copy with Alt+O, view history with Alt+Shift+O
  • Copy History: Session-based history of recent copies (last 20 items)
  • Quick Navigation: Select from history to jump to any previously copied location
  • Relative Paths: Automatically uses workspace-relative paths
  • Cross-Platform: Normalizes path separators for consistency

Screenshots

Single Line Copy Single-line selection with auto-dismissing notification

Multi-Line Copy Multi-line selection in Claude Code format with @ prefix

Copy History Copy history (Alt+Shift+O) showing recent copies with timestamps

Output Formats

The extension automatically chooses the best format based on your selection:

Multi-Line Selection (Claude Code Format)

When you select multiple lines, the output includes an @ prefix for Claude Code:

@packages/r3bl-copy-selection-path-and-range/src/extension.ts#L6-14

This format is optimized for use in Claude Code prompts where the @ symbol tells Claude to reference that specific file and line range.

Single-Line Selection (IDE Format)

When you have a single line selected or cursor on a line:

packages/r3bl-copy-selection-path-and-range/src/extension.ts:6

This format is compatible with most IDEs and terminals that support file:line navigation.

Requirements

  • VS Code 1.95.0 or higher
  • File must be in an open workspace

Usage

Copy Path (Alt+O)

  1. Select lines in your editor (or just place cursor on a line)
  2. Press Alt+O
  3. Path with line range is copied to clipboard
  4. Notification shows what was copied (auto-dismisses)

View Copy History (Alt+Shift+O)

  1. Press Alt+Shift+O to open copy history
  2. Browse your recent copies (up to 20 items)
  3. Select any item to jump to that file and line range
  4. History shows relative timestamps ("just now", "5 minutes ago", etc.)

Command Palette

  1. Open Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
  2. Type "Copy File Path with Selection Range" or "Show Copy History"
  3. Press Enter

Use Cases

Claude Code Prompts

Share specific code sections in your prompts:

Can you review the error handling in @src/services/api.ts#L45-67?

Claude Code will automatically reference that exact section of your code.

Code Reviews

Share precise locations with team members:

Please check the logic in src/utils/parser.ts:123

Documentation

Reference specific implementations in your docs:

See the authentication flow in @src/auth/oauth.ts#L15-42

Issue Tracking

Link to exact code locations in bug reports:

The bug occurs in src/components/Form.tsx:89

Commands

  • R3BL: Copy File Path with Selection Range - Copy the current file path with selection range to clipboard
  • R3BL: Show Copy History - Show history of recently copied paths and navigate to any location

Keyboard Shortcuts

Shortcut Command When
Alt+O Copy File Path with Selection Range Editor has focus
Alt+Shift+O Show Copy History Always

You can customize these shortcuts in VS Code's Keyboard Shortcuts settings.

How It Works

  1. Path Calculation: Gets relative path from workspace root
  2. Line Detection: Determines if selection spans multiple lines
  3. Format Selection:
    • Multi-line → Claude Code format with @ prefix
    • Single-line → IDE format
  4. Clipboard: Copies formatted string
  5. History Storage: Adds to in-memory session history (last 20 items)
  6. Notification: Shows confirmation (auto-dismisses)

Copy History

  • Stored in memory (session-only, cleared on reload)
  • Keeps last 20 copied items
  • Shows file path, line range, and relative timestamp
  • Quick pick interface for easy navigation
  • Press Alt+Shift+O to access anytime

Shared Infrastructure

This extension uses the R3BL Shared extension for centralized services across all R3BL extensions (message queuing, global configuration, and more).

See the R3BL Shared documentation for available services, API usage, and configuration options.

Release Notes

See CHANGELOG.md for detailed release notes and version history.

License

MIT

Contributing

Found a bug or have a feature suggestion? Please open an issue at: https://github.com/r3bl-org/r3bl-vscode-extensions/issues


Copy and share context with Claude Code effortlessly!

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