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 selection with auto-dismissing notification
Multi-line selection in Claude Code format with @ prefix
Copy history (Alt+Shift+O) showing recent copies with timestamps
The extension automatically chooses the best format based on your selection:
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.
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)
- Select lines in your editor (or just place cursor on a line)
- Press
Alt+O
- Path with line range is copied to clipboard
- Notification shows what was copied (auto-dismisses)
View Copy History (Alt+Shift+O)
- Press
Alt+Shift+O to open copy history
- Browse your recent copies (up to 20 items)
- Select any item to jump to that file and line range
- History shows relative timestamps ("just now", "5 minutes ago", etc.)
Command Palette
- Open Command Palette (
Ctrl+Shift+P or Cmd+Shift+P)
- Type "Copy File Path with Selection Range" or "Show Copy History"
- 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
- Path Calculation: Gets relative path from workspace root
- Line Detection: Determines if selection spans multiple lines
- Format Selection:
- Multi-line → Claude Code format with
@ prefix
- Single-line → IDE format
- Clipboard: Copies formatted string
- History Storage: Adds to in-memory session history (last 20 items)
- 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!