The tag stack
The tag stack is perhaps the least known of all of Vim’s lists — probably because it’s a bit more specific.
It keeps track of the tags that you’ve jumped to, and allows you to jump back and forth between them.
What are the tags we speak of? Well — Vim has ctags support which helps us achieve basic jump-to-object capabilities without requiring special language servers and plugins. These days, ctags is fairly old tech, and you’d usually want to use something a bit more robust like an LSP client. Most of the time, the tag stack is commandeered by Vim plugins, so the use of the word “tag” is actually a bit of a historical artifact here.
You can think of the tag stack as a list of your previous ‘jumps to definitions’. Most of the time, you’ll get away with just the jumplist. But the tag stack is slightly more specialized if you think that’s useful.
The editor is set up so that there are tags for the variables foo, bar, and baz. With your cursor on one of those words, <C-]> jumps to its definition, and <C-t> jumps back again. The checklist below walks you through a round trip to foo’s definition and back, then another to bar’s — and baz is sitting there when you want to try one on your own.
We’re going to explore ctags in a future lesson, so we’ll cover the rest of the details when the time is right. For now, it’s worth being aware that <C-]> means ‘jump to tag’ and <C-t> means ‘jump back again’.