How do I jump to a tag matching a partial name or pattern when I don't know the exact tag name?
Answer
:tjump /pattern
Explanation
:tjump is a smarter variant of :tag. When a / prefix is used, it treats the argument as a regex pattern rather than a literal name — so you can match any tag whose name contains your pattern. If only one tag matches, Vim jumps directly to it. If multiple tags match, an interactive list is displayed for you to choose from.
How it works
:tag /pattern— jump to the first tag matching pattern, no choice offered:tjump /pattern— show a numbered list if multiple matches; jump directly if only one/patternuses Vim's standard regex syntax- Without the
/prefix,:tjump nameworks like a smart:tagthat prompts on ambiguity
Example
With a tags file containing UserController, UserModel, UserService:
:tjump /User
Shows a numbered list:
# pri kind tag file
1 F f UserController app/controllers/user_controller.rb
2 F f UserModel app/models/user.rb
3 F f UserService app/services/user_service.rb
Enter nr of choice (<CR> to abort):
Type the number to jump directly to that definition.
Tips
- Use
:tselect /patternif you always want to choose, even for a single match - After jumping,
<C-t>or:popreturns you to where you came from - Combine with
:set tags=./tags;to auto-discover tag files in parent directories - Works in all languages — requires a
tagsfile generated byctags,gtags, or similar