R3BL Copy Selection Path and Range

Quickly copy file paths with selected line ranges in standard compiler syntax (path:line
or path:start-end). Perfect for sharing code references with AI coding agents (Claude
Code, Gemini CLI, etc.), in prompts, documentation, or team communication.
Features
- Standard Compiler Syntax: Multi-line selections use
path:<start>-<end> format
- Single-Line / Cursor: Single-line selections use
path:<line> format
- No
@ Prefix: Clean relative or absolute paths directly usable by compilers, IDEs,
and tools
- 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
- Smart Paths:
- Relative Paths: Automatically uses workspace-relative paths for files inside the
workspace
- Absolute Paths: Fallback to full absolute paths for files outside the workspace
- Cross-Platform: Normalizes path separators for consistency
Screenshots
Single-line selection with auto-dismissing notification
Multi-line selection in standard compiler syntax
Copy history (Alt+Shift+O) showing recent copies with timestamps
The extension produces standard compiler syntax based on your selection:
Multi-Line Selection
When you select multiple lines, the output uses standard line coordinates
(path:start-end):
packages/r3bl-copy-selection-path-and-range/src/extension.ts:6-14
This format is standard across compilers and tools, and is directly understood by coding
agents.
Single-Line Selection
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.
Outside Workspace (Absolute Path)
When you copy a path for a file outside of the VS Code workspace, the extension provides
the full absolute path:
/home/user/Downloads/script.py:10-25
It still maintains line range formatting without any @ prefix.
Requirements
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
Coding Agent Prompts
Share specific code sections in your prompts:
Can you review the error handling in src/services/api.ts:45-67?
The Coding Agent 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:15-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 if file is inside workspace
- Falls back to full absolute path if file is outside workspace
- Line Detection: Determines if selection spans multiple lines
- Format Selection:
- Multi-line → standard compiler range format (
path:start-end)
- Single-line → standard compiler line format (
path:line)
- 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 Coding Agents effortlessly!