How do I navigate back through the tag stack after jumping to definitions?
Answer
:pop or <C-t>
Explanation
When you jump to a tag definition with <C-]>, Vim pushes your location onto a tag stack. You can navigate this stack to return to previous positions, view the stack contents, and even jump to specific entries — essential for code exploration.
How it works
<C-]>— jump to the tag under the cursor (pushes to stack)<C-t>or:pop— go back one level in the tag stack:tags— show the full tag stack with positions:tag— go forward one level (after going back):{n}pop— go back n levels at once
Example
:tags
# TO tag FROM line in file
1 1 main 15 src/app.py
2 1 process 8 src/main.py
> 3 1 validate 42 src/process.py
Currently at 'validate' — press <C-t> to return to 'process'
Tips
:tselect {tag}lists all matching tags when there are multiple definitionsg<C-]>shows a selection menu when multiple tags match:tnextand:tprevcycle through multiple definitions of the same tag- The tag stack is separate from the jump list (
<C-o>/<C-i>)