vimtricks.wiki Concise Vim tricks, one at a time.

How do I jump to a match across included files using Vim's include search?

Answer

:ijump /MySymbol/

Explanation

:ijump is an include-aware jump command that searches the current file plus files discovered through your include and path settings, then jumps directly to a selected match. It is useful when you do not have tags for a codebase yet, but still need fast cross-file symbol lookup. Compared to project-wide grep, it follows include structure instead of scanning everything blindly.

How it works

  • :ijump /MySymbol/ searches for the pattern in the current file and in files reachable through include scanning
  • Vim lists candidate matches and lets you jump to one interactively
  • The behavior depends on options such as include, includeexpr, and path

This makes it a good fallback when tags are stale or unavailable, especially in generated or vendor-heavy projects where include relationships are more reliable than filename globs.

Example

Current file includes:
- include/user.h
- include/account.h
:set path+=include/**
:set include=#include
:ijump /UserId/

Vim presents matches across the include graph and jumps to the chosen location.

Tips

  • Use :ilist /pattern/ first if you want to inspect all matches before jumping
  • Keep path recursive (**) for deep include trees
  • If your language uses custom include syntax, tune include or includeexpr to improve results

Next

How do I jump to a definition-style pattern match using Vim's define search?