Better Copy Path with Lines

🚀 VSCode extension for copying file paths with line numbers | 中文文档
💡 What is This?
A VSCode extension that copies file paths with line numbers in a single click. Perfect for:
- 📝 Sharing code references in GitHub issues/PRs
- 💬 Discussing specific code lines in Slack/Teams
- 📚 Writing documentation with precise code locations
- 🐛 Reporting bugs with exact line numbers
✨ Features
Quick Copy from Anywhere
- Right-click in line number area → Get
src/app.ts:42

- Right-click in editor → Get path with current line

- Works with single line, range (
10-20), or multiple selections (5, 10, 15)
Two Formats
- 📂 Relative Path:
src/components/Button.tsx:42
- 📁 Absolute Path:
/Users/me/project/src/components/Button.tsx:42
Customizable
- 🔧 Path separator:
/ or \ or system default
- 🔧 Range connector:
- or ~ (e.g., 10-20 vs 10~20)
- 🔧 Selection separator:
, or ; or space
🎯 Why This Fork?
This is an enhanced fork of qishan233/copy-path-with-line-number
✨ Key Improvements
| Feature |
Original |
This Fork |
| Menu Speed |
3 clicks (submenu) |
2 clicks (direct) |
| Menu Options |
4 options |
2 focused options |
| Line Gutter |
❌ Broken |
✅ Working |
| Command Format |
Verbose labels |
Clean Path:Line format |
| Focus |
Mixed features |
Line numbers only |
🚀 What's Different
Speed & Simplicity
- ⚡ 33% faster - Removed submenus for direct access
- 🧠 50% less cognitive load - Only 2 relevant options
- 🎯 Clear focus - Line number context is the core value
Fixed Critical Issues
- ✅ Line number gutter now works - Fixed VSCode API handling
- ✅ Cleaner UX - Removed redundant non-line commands (use VSCode's native "Copy Path" instead)
Better Design
- 📝 Commands use clean format:
Copy Relative Path:Line / Copy Absolute Path:Line
- 🎨 Appears only in relevant contexts (editor & line gutter)
- 🔧 Same powerful configuration options (separators, connectors, etc.)
📥 Installation
Option 1: VS Code Marketplace (Recommended)
- Open VSCode
- Go to Extensions (
Ctrl+Shift+X / Cmd+Shift+X)
- Search for "Better Copy Path with Lines"
- Click Install
Or install via CLI:
code --install-extension MarkShawn2020.better-copy-path-with-lines
Option 2: Open VSX Registry
For VSCodium, Code-OSS, or other VS Code compatible editors:
# VSCodium
codium --install-extension MarkShawn2020.better-copy-path-with-lines
# Or download from https://open-vsx.org/extension/MarkShawn2020/better-copy-path-with-lines
Option 3: Manual Installation
- Download the latest
.vsix from GitHub Releases
- In VSCode:
Extensions → ... → Install from VSIX
Option 4: From Source
git clone https://github.com/MarkShawn2020/better-copy-path-with-lines.git
cd better-copy-path-with-lines
npm install
npm run compile
# Press F5 to launch Extension Development Host
🎬 Usage
Quick Start
Right-click in line number area or editor:
└─ Copy Relative Path:Line → src/app.ts:42
└─ Copy Absolute Path:Line → /Users/me/project/src/app.ts:42
Multi-line selection:
Select lines 10-20 → Copy → src/app.ts:10-20
Multiple selections → Copy → src/app.ts:5, 10, 15
Configuration
Customize separators and connectors in VSCode settings:
{
"copyPathWithLineNumber.path.separator": "slash", // "/" or "\" or "system"
"copyPathWithLineNumber.range.connector": "dash", // "-" or "~"
"copyPathWithLineNumber.selection.separator": "comma", // "," or ";" or " "
"copyPathWithLineNumber.show.message": true // Show notification
}
Examples:
Default: src/components/Button.tsx:42-55
With tilde: src/components/Button.tsx:42~55
With space: src/components/Button.tsx:10 20 30
🔄 Comparison with Original
For a complete feature list of the original extension, see the original repository.
What we kept:
- ✅ Line number copying with ranges
- ✅ Custom separators and connectors
- ✅ Multi-line selection support
- ✅ i18n (English & Chinese)
What we changed:
- 🎯 Removed: Non-line commands (explorer/tab contexts) - use VSCode's native "Copy Path"
- 🎯 Removed: Submenus - direct command access
- 🎯 Fixed: Line number gutter context menu
- 🎯 Simplified: Command labels to
Path:Line format
📊 Technical Details
Architecture Highlights
- Pattern: Decorator + Strategy + Command
- Type Safety: Full TypeScript with strict mode
- Performance: Zero dependencies (except VSCode API)
- Size: ~194 KB packaged
Key Technical Improvements
v0.1.2 - Fixed VSCode line number context API
// VSCode passes {lineNumber: number, uri: Uri} from gutter
// Added proper detection and extraction
v0.1.1 - Focused refactoring
- Removed 2 commands (kept only line-enabled)
- Flattened menu structure
- Simplified all code paths
🐛 Known Issues
None currently. Report issues at: https://github.com/MarkShawn2020/better-copy-path-with-lines/issues
🤝 Contributing
Contributions welcome! This project uses automated releases via Conventional Commits.
Quick Start:
# Feature (triggers 0.1.4 → 0.2.0)
git commit -m "feat: add new feature"
# Bug fix (triggers 0.1.4 → 0.1.5)
git commit -m "fix: resolve bug"
Pushing to main automatically:
- ✅ Analyzes commits
- ✅ Bumps version
- ✅ Publishes to VS Code Marketplace & Open VSX
- ✅ Creates GitHub release
See CONTRIBUTING.md for detailed guidelines.
We prioritize:
- Speed and simplicity
- Line number context use cases
- Clean, maintainable code
📜 License
MIT License - Same as original project
🙏 Credits
- Original Author: qishan233
- Fork Maintainer: MarkShawn2020
- Improvements: Focused refactoring + critical bug fixes
📝 Release Notes
0.1.3 (Latest)
⚡ Improved Defaults
- Changed default range connector from
~ to - (industry standard: 10-20 instead of 10~20)
- Matches GitHub, GitLab, grep, and most developer tools
- Easier to type (no Shift key needed)
~ still available as configuration option
0.1.2
🐛 Critical Bug Fix
- Fixed line number gutter context menu (VSCode API
{lineNumber, uri} handling)
- Removed debug logging
0.1.1
🚀 Major Refactoring
- Removed non-line commands (use VSCode native "Copy Path")
- Flattened menu structure (2 clicks vs 3)
- Simplified labels to
Path:Line format
- Only show in editor & line gutter contexts
0.1.0
- Added line number gutter support
Earlier Versions
See original repository for versions 0.0.1 - 0.0.7
Made with ❤️ for developers who share code references frequently