Overview
Harpoon is a lightning-fast file navigation plugin that lets you mark important files and quickly jump between them. Think of it as bookmarks for your most frequently accessed files in a project. Plugin: ThePrimeagen/harpoon (branch: harpoon2)Features
- Mark/bookmark important files for quick access
- Toggle quick menu to see all marked files
- Navigate forward and backward through marked files
- Remove files from the mark list
- Lightning-fast file switching
- Per-project mark lists
Configuration
Harpoon is configured inlua/magictt/plugins/harpoon.lua:
Keybindings
Primary Keymaps
| Keymap | Action | Description |
|---|---|---|
<leader>ha | Add file | Add current file to Harpoon list |
<C-e> | Toggle menu | Open/close Harpoon quick menu |
<C-p> | Previous | Navigate to previous marked file |
<C-n> | Next | Navigate to next marked file |
<leader>hr | Remove | Remove current file from Harpoon list |
Inside Harpoon Menu
When the quick menu is open:| Key | Action |
|---|---|
<CR> | Open selected file |
dd | Delete entry from list |
j/k | Navigate up/down |
q or <Esc> | Close menu |
Usage Examples
Basic Workflow
-
Mark your important files:
- Open a file you want to bookmark
- Press
<leader>hato add it to Harpoon - Repeat for 3-5 files you frequently switch between
-
View your marks:
- Press
<C-e>to see all marked files - The quick menu shows file names and paths
- Press
-
Navigate between marks:
- Press
<C-n>to go to the next file - Press
<C-p>to go to the previous file - Or use
<C-e>to open the menu and select directly
- Press
Add Current File
<leader>ha to add it to your Harpoon list.
Quick Menu Navigation
<C-e> to see all your marked files and select one to open.
Cycle Through Files
Remove Files
<leader>hr while in a marked file to remove it from the list.
Tips and Tricks
When to Use Harpoon
Harpoon is perfect for:- Switching between a controller, service, and test file
- Navigating between frontend component and its styles
- Jumping between related configuration files
- Working on a feature spanning multiple files
Harpoon vs Telescope
- Telescope (
<leader>ff): Use when exploring or searching for files - Harpoon: Use when rapidly switching between known files
Typical Marking Strategy
Mark 3-5 files you’re actively working on:- Main implementation file
- Test file
- Related component/module
- Configuration file
- Documentation
Per-Project Marks
Harpoon maintains separate mark lists for each project directory. When you switch projects, you’ll see different marks. This makes it perfect for working on multiple projects.Quick Menu Editing
In the quick menu (<C-e>):
- Reorder files by cutting (
dd) and pasting (p) - Delete marks you no longer need
- See file paths to avoid confusion
Keyboard-Centric Workflow
Harpoon encourages a keyboard-only workflow:- Open files with Telescope once
- Mark them with Harpoon
- Navigate with
<C-n>and<C-p>without leaving home row
Integration with Which-Key
The config registers Harpoon with which-key:<leader>h and wait to see all Harpoon keybindings.
Advanced Usage
Clear All Marks
To start fresh, open the quick menu (<C-e>) and delete all entries with dd.
Check Current Mark Position
The quick menu shows which file is currently open (highlighted).Muscle Memory
After a few days of use, you’ll develop muscle memory:- File 1:
<C-e>then1 - File 2:
<C-e>then2 - Or cycle with
<C-n>repeatedly
Harpoon 2
This config uses Harpoon 2 (branch:harpoon2), which features:
- Improved API and performance
- Better list management
- More reliable persistence
- Enhanced UI
Workflow Example
Related Plugins
Troubleshooting
Marks don’t persist- Harpoon 2 stores marks per project directory
- Ensure you’re in the same working directory
- Check
:pwdto see current directory
- Verify
<C-e>isn’t mapped by another plugin::map <C-e> - Check for errors:
:messages
- These may conflict with other plugins
- Check mappings:
:map <C-n>and:map <C-p> - Consider remapping if needed
- Ensure which-key is loaded before Harpoon
- Check
:Lazyplugin load order