When I invoke :tags command in vim, the result varies depending on vim windows. So I wonder the scope of the result of the vim command :tags. I guess it would be one of below:

  1. g: Global
  2. s: Script-local (like "static" in C)
  3. l: Function-local
  4. a: Function argument
  5. v: Vim internal
  6. b: Buffer local
  7. w: Window local
  8. t: Tab local

The above is from this

1 Answer 1


:help :tags prints the current state of the :help tag-stack, which is indeed window-local (tough the documentation is sadly not explicit about it).

But the scopes you listed in your question only matter for variables. They are pretty much meaningless in the context of :tags, and thus irrelevant.

That said, if you want to save the tag stack of the current window to a variable, then it makes the most sense to make that variable window-local with the appropriate scope:

let w:tag_stack = gettagstack()

Other than that, scopes are irrelevant.

  • I maybe understood half of what you said. I received that you answered the scope is similar to the windows local. What I don't understand is why you said irrelevant. I will study the :help :tags and :help tag-stack. Thank you again!
    – Jumogehn
    Commented Dec 4, 2023 at 7:50
  • @Jumogehn what do you think the :tags command does? Maybe you are misunderstanding it. Tags are not variables.
    – Friedrich
    Commented Dec 4, 2023 at 8:19
  • @Friedrich Watching the tag-stack value varies depending on vim windows gave me a question - The tag-stack is not globally behave. And they seemed to belong to each windows. So I guessed tag-stack is maybe behaves similar to a variable and it maybe have scopes... And still I guess the tag-stack is maintained by some variables and the variables may have scope and that is why the tag-stack appears differently on windows
    – Jumogehn
    Commented Dec 4, 2023 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.