Copy code references in a format optimized for AI coding assistants like Claude Code. Quickly reference specific code locations with file paths and line numbers.
Place your cursor on any line and copy a reference in the format: src/utils/helper.js L15
Select multiple lines to copy range references: src/utils/helper.js L15-L20
- Simple:
src/utils/helper.js L15(default) - Preview:
src/utils/helper.js L15: const result = calculate(x, y);
- Keyboard Shortcut:
Ctrl+Shift+C(Windows/Linux) orCmd+Shift+C(Mac) - Command Palette: "ClipCodeRef: Copy Code Reference"
- Right-click Menu: "Copy Code Reference"
- Single Workspace: Paths relative to workspace root
- Multi-root Workspace: Intelligent workspace name prefixing when needed
- External Files: Absolute paths with home directory shortened to
~ - Unsaved Files: Uses
Untitled-1 L<line>format
Install from the VS Code Marketplace by searching for "ClipCodeRef" or visit the extension page.
- Place cursor on line 42 in
src/app.js - Press
Cmd+Shift+C(Mac) orCtrl+Shift+C(Windows/Linux) - Result copied to clipboard:
src/app.js L42
- Select lines 15-20 in
src/utils/helper.js - Use any activation method
- Result:
src/utils/helper.js L15-L20
When clipCodeRef.format is set to "preview":
src/utils/helper.js L15: const result = calculate(x, y);
When file paths might be ambiguous:
[frontend]/src/components/App.js L10
[backend]/src/utils/helper.js L25
This extension contributes the following settings:
- Type:
string - Default:
"simple" - Options:
"simple"|"preview" - Description: Choose output format for code references
- Type:
boolean - Default:
true - Description: Remove leading/trailing whitespace from code preview
- Type:
number - Default:
80 - Description: Maximum line length for code preview (longer lines are truncated)
- Type:
string - Default:
"auto" - Options:
"auto"|"always"|"never" - Description: How to handle multi-root workspaces
"auto": Include workspace name only when paths would be ambiguous"always": Always include workspace name"never": Never include workspace name
- Type:
number - Default:
50 - Description: Maximum number of lines allowed for range selections
Add to your VS Code settings.json:
{
"clipCodeRef.format": "preview",
"clipCodeRef.trimWhitespace": true,
"clipCodeRef.maxLineLength": 100,
"clipCodeRef.multiRootBehavior": "auto",
"clipCodeRef.maxRangeLines": 25
}- VS Code 1.70.0 or higher
- No external dependencies required
- Multiple cursors are not supported (shows error message)
- Very large range selections (>50 lines by default) require configuration adjustment
- Web version of VS Code has clipboard API limitations
Perfect for developers who:
- Use AI coding assistants like Claude Code, GitHub Copilot Chat
- Need to reference specific code locations in documentation
- Want to quickly share code references with team members
- Work with multiple projects and need efficient path handling
- Copy operations complete in <100ms for files up to 10,000 lines
- No impact on VS Code startup time
- Minimal memory footprint
- Report issues on GitHub
- Feature requests welcome
- Star the project if you find it useful!
This project uses automated version bumping and dual marketplace publishing.
For maintainers:
-
GitHub Actions (Recommended):
- Go to Actions tab β "Version Bump" workflow
- Click "Run workflow" and select version type (patch/minor/major)
- Automatically updates package.json, creates tag, and triggers release
-
Local Development:
npm run version:patch # Bug fixes (1.0.0 β 1.0.1) npm run version:minor # New features (1.0.0 β 1.1.0) npm run version:major # Breaking changes (1.0.0 β 2.0.0)
-
Manual Release:
- Go to Actions tab β "Release" workflow
- Click "Run workflow" and enter the tag name (e.g.,
v1.0.3) - Releases published to both VS Code Marketplace and Open VSX Registry
npm install # Install dependencies
npm run watch # Development mode
npm run compile # Build + type check + lint
npm test # Run test suite
npm run package-vsix # Create .vsix packageBuilt for developers using AI coding assistants π€