How do I jump to a tag in a new split window showing all matching tags?
Answer
<C-w>g]
Explanation
<C-w>g] splits the window and then runs :tselect for the identifier under the cursor, displaying a numbered list of all matching tags so you can pick the exact definition you want. This combines the convenience of a split with the disambiguation power of :tselect, making it invaluable in large codebases where a function name appears in multiple files or implementations.
How it works
<C-w>g]= open a new horizontal split, then run:tselect {word-under-cursor}:tselectlists all matching tags with their file paths and kinds (function, variable, class, etc.)- Type the number of the match to jump to it, or
<CR>to cancel - The tag stack is updated, so
<C-t>returns you to the originating buffer
Compare to related commands:
| Command | Behavior |
|---|---|
<C-]> |
Jump directly to first matching tag |
g] |
Show :tselect list in current window |
<C-w>] |
Split and jump to first matching tag |
<C-w>g] |
Split and show :tselect list |
<C-w>g<C-]> |
Split and jump using enhanced tag lookup |
Example
With cursor on parseConfig:
1: kind:f file:src/config.c static int parseConfig(const char *)
2: kind:f file:tests/config_test.c static int parseConfig(const char *)
Type number and <Enter> (empty cancels):
Type 1 or 2 to jump to the desired definition in the split.
Tips
- Use
<C-t>after jumping to return to where you came from - Combine with
ctagsor a language server that generates tags for best results :tselect {name}can be called directly from the command line to browse all tags matching a pattern