How do I jump to a definition-style pattern match using Vim's define search?
Answer
:djump /MY_MACRO/
Explanation
:djump searches for matches using Vim's definition search rules and jumps to the selected hit. It is designed for definition-like navigation, so it works best when your define option reflects the language forms you care about (functions, macros, constants, etc.). This gives you a lightweight navigation path when tags are missing or incomplete.
How it works
:djump /MY_MACRO/scans the current file and related include targets for definition matches- Matching uses your current
define,include, andpathoptions - Vim presents candidates and jumps directly to the chosen location
This can be faster than broad grep when your project has a predictable declaration style and include graph.
Example
:set define=^\s*#\s*define
:set path+=include/**
:djump /MAX_BUFFER/
With those settings, :djump focuses on C-style macro definitions and jumps to the declaration you select.
Tips
- Pair
:dlist /pattern/with:djump /pattern/when you want to preview before jumping - Tune
defineper filetype usingautocmd FileTypefor better accuracy - Use tags for primary navigation and
:djumpas a robust fallback when tags are stale