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

How do I choose from multiple tag matches when a tag has several definitions?

Answer

:tselect

Explanation

When a tag has multiple definitions (e.g., an overloaded function), :tselect presents a list and lets you choose which one to jump to.

How it works

  • :tselect tagname shows all matching tag entries
  • Each entry shows the file, line number, and kind
  • Type a number and press Enter to jump to that definition

Example

:tselect process
  # pri kind tag          file
  1 F   f    process      src/main.go:42
  2 F   f    process      src/utils.go:15
Type number and <Enter>: 

Tips

  • g<C-]> is the normal-mode equivalent
  • :tjump is similar but jumps directly if there is only one match
  • g] lists matching tags for the word under cursor
  • :tnext and :tprev cycle through multiple tag matches

Next

How do you yank a single word into a named register?