Vim keeps a stack of tags (displayable with
:tags) that the user jumps to and from, similar to the jump list (displayable with
:jumps). The jump list can be cleared with the
:clearjumps command. This is convenient because I can jump to the “root” of where I'm working, clear the jump list, and if I ever need to return there I can simply hold CTRL-O to “unwind” all the way to where I started.
In theory, one could do the same thing with tags: jump to the initial point of interest, clear the tag stack, navigate “more deeply” into the program by following tags with CTRL-], then hold CTRL-T to pop all the way back up to the tag that was initially jumped to. The problem is that there doesn't appear to be a corresponding
:cleartags command for step two, and it’s quite easy to accidentally jump past the first tag and end up somewhere I have no reason to be (usually the first line of whichever file happened to be the first argument to Vim). So my question is:
- Am I correct in thinking that there's nothing like a
- If so, is there a workaround? Could it be implemented as a Vimscript function? (A quick search through the builtin functions didn’t yield anything that could be used to manipulate or even access the tag stack.)
I’m using Vim 8.0 with patches 1–427 and most optional features compiled in.