Code Highlighter
Highlight your code with colors — just like a real highlighter pen. Features • Getting Started • Shortcuts • Commands • How It Works • Contributing ✨ Features🎨 Six Vivid ColorsPick from yellow, green, blue, pink, orange, or red — each with a carefully tuned semi-transparent overlay that's easy on the eyes and works with any theme.
🧰 Toolbar SidebarA dedicated Activity Bar panel gives you everything in one place:
⚡ Instant Keyboard ShortcutPress 🧹 Eraser ModeSwitch to the Eraser in the sidebar toolbar, then:
💾 Persistent HighlightsYour highlights are saved per workspace and survive across VS Code restarts. Close VS Code, reopen your project — everything is exactly where you left it. ✏️ Edit-AwareHighlights automatically adjust when you edit your code:
🖱️ Right-Click MenuRight-click on selected text to see "Highlight Selection" in the context menu. Right-click anywhere to "Remove Highlight at Cursor". 🔍 Click to NavigateClick any highlight in the sidebar to jump directly to that line in the editor. The highlighted range is selected and scrolled into view. 🚀 Getting StartedInstall from Marketplace
Install from
|
| Shortcut | Action |
|---|---|
Ctrl+Alt+H |
Highlight selection with active color (or erase in eraser mode) |
💡 Tip: On Mac, use
Cmd+Alt+Hinstead.
📋 Commands
All commands are available via the Command Palette (Ctrl+Shift+P):
| Command | Description |
|---|---|
Code Highlighter: Highlight / Erase Selection |
Highlight the selected text or erase highlights (depends on active tool) |
Code Highlighter: Remove Highlight at Cursor |
Remove any highlight under the cursor |
Code Highlighter: Clear All Highlights in File |
Remove all highlights in the current file |
Code Highlighter: Clear All Highlights in Workspace |
Remove every highlight across all files |
🔧 How It Works
Highlight Storage
Highlights are stored in your workspace state — a per-project storage managed by VS Code. This means:
- ✅ Highlights persist across VS Code restarts
- ✅ Each project has its own independent highlights
- ✅ No files are modified — highlights are metadata only
- ✅ No cloud sync needed
Range Tracking
Each highlight stores its exact position (start line, start character, end line, end character). When you edit your code, the extension listens to document changes and:
- Shifts highlights below the edit point when lines are inserted/deleted
- Removes highlights that fall within a deleted range
- Adjusts highlights that partially overlap with edits
Architecture
┌──────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ extension.ts │────▶│ HighlightManager │────▶│ workspaceState │
│ (commands & │ │ (CRUD, decorate, │ │ (persistence) │
│ events) │ │ range tracking) │ └─────────────────┘
└──────┬───────┘ └────────┬─────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────────┐
│ Sidebar │◀───▶│ VS Code Editor │
│ (toolbar & │ │ (decorations) │
│ list UI) │ └──────────────────┘
└──────────────┘
🎨 Highlight Colors
| Color | Preview | Use Case Ideas |
|---|---|---|
| 🟡 Yellow | rgba(255, 235, 59, 0.35) |
Important logic, key algorithms |
| 🟢 Green | rgba(76, 175, 80, 0.35) |
Working/approved code, good patterns |
| 🔵 Blue | rgba(66, 165, 245, 0.35) |
References, dependencies, imports |
| 🩷 Pink | rgba(236, 64, 122, 0.35) |
Bugs, issues, needs attention |
| 🟠 Orange | rgba(255, 152, 0, 0.35) |
Warnings, temporary code, TODOs |
| 🔴 Red | rgba(244, 67, 54, 0.35) |
Critical issues, deprecated code |
🛠️ Building from Source
# Clone the repository
git clone https://github.com/MihirShah07/code-highlighter.git
cd code-highlighter
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch mode (auto-recompile on changes)
npm run watch
Testing Locally
- Open the project folder in VS Code
- Press F5 to launch the Extension Development Host
- The extension is active in the new window — try highlighting some code!
Packaging
# Install the VS Code Extension CLI
npm install -g @vscode/vsce
# Create the .vsix package
vsce package
# Install locally
code --install-extension code-highlighter-1.0.0.vsix
🤝 Contributing
Contributions are welcome! Here's how to get started:
- Fork this repository
- Create a branch for your feature:
git checkout -b feature/my-feature - Make your changes and test them with F5
- Commit with clear messages:
git commit -m "Add: new feature" - Push and open a Pull Request
Ideas for Contributions
- [ ] Custom colors (let users define their own palette)
- [ ] Export/import highlights
- [ ] Highlight gutters (colored markers in the editor gutter)
- [ ] Search within highlights
- [ ] Highlight sharing between team members
📄 License
This project is licensed under the MIT License.
Made with 🖍️ by Mihir Shah