How do I jump to a tag and get an interactive list when multiple definitions exist in Vim?
Answer
:tjump
Explanation
:tjump {identifier} is the smart tag-jumping command: it jumps directly when there is only one matching tag, but shows an interactive numbered list when multiple definitions exist. This combines the immediacy of <C-]> (which always jumps to the first match) with the selectivity of :tselect (which always shows the list).
How it works
:tjump {identifier}— jump if unique, otherwise show selection list:tjump /{pattern}— same behaviour using a regex pattern to match tag names- Normal-mode equivalent:
g]operates on the word under the cursor - After selecting from the list,
<C-t>or:popnavigates back up the tag stack
Example
For a symbol with a single definition, :tjump init jumps immediately. For one with multiple definitions:
# pri kind tag file
1 F f init src/main.c
2 F f init src/module.c
Type number and <Enter> (q or empty cancels):
Type 2 to jump to src/module.c.
Tips
- Use
:tjump /^Myto match all tags beginning withMyusing a regex :tselect {id}always shows the list even for unique matches — useful when you want to confirm which definition you are jumping to<C-]>in normal mode always jumps to the first tag match without prompting; preferg]or:tjumpfor ambiguous symbols- See
:help :tjumpfor the full command reference