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

How do I pick from multiple tag matches instead of jumping to the first one?

Answer

g]

Explanation

g] is the disambiguation-aware alternative to <C-]>. When the word under your cursor has multiple tag definitions (overloaded functions, multiple files with the same symbol), g] presents a numbered list of all matches and lets you choose which one to jump to.

How it works

  • <C-]> — jump immediately to the first (highest-priority) tag match
  • g] — show all tag matches in a list, prompt for a number, then jump
  • :tselect {name} — same as g] but for an arbitrary name instead of cursor word
  • :tjump {name} — jumps directly if there's only one match, shows the list if there are multiple

Example

With cursor on parseConfig, pressing g] displays:

  # pri kind tag               file
  1 F   f    parseConfig       src/config.c
  2 F   f    parseConfig       src/legacy.c
  3 F   m    parseConfig       lib/util.go
Enter nr of choice (<CR> to abort):

Type 2<CR> to jump to the definition in legacy.c.

Tips

  • After jumping, use <C-t> to return to the previous location in the tag stack
  • :tprev and :tnext cycle through tag matches without the picker — useful if you already know the order
  • :tags shows your full tag stack so you can see how deep you've navigated
  • For LSP-aware projects in Neovim, g] still works with :help tagsrch but you may prefer vim.lsp.buf.references() for cross-file accuracy

Next

How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?