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

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
  • /pattern uses Vim's standard regex syntax
  • Without the / prefix, :tjump name works like a smart :tag that 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 /pattern if you always want to choose, even for a single match
  • After jumping, <C-t> or :pop returns 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 tags file generated by ctags, gtags, or similar

Next

What is the difference between the inner word (iw) and inner WORD (iW) text objects in Vim?