← All lessons

15. The Changelist Jumplist And Tag Stack

Step 5 of 5

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 artefact 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 specialised if you think that’s useful.

Let’s learn the basics of the tag system in the editor. The editor is set up so that there are tags for the variables foo, bar, and baz. If you place your cursor over any of these words, you can use <C-]> to jump to their definitions. To jump backwards in the taglist, it’s <C-t>.

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’.

Loading editor…