I knew you could scope a variable by prefixing it with g: b:, etc. but I only just discoverred that the prefix itself references a dictionary containing all the scoped variables. For example,

:echo b:c_minlines


:echo b:
{'c_minlines': 50, 'did_indent': 1, 'current_syntax': 'c', ...}

Is this documented somewhere?

1 Answer 1


Poking around with :helpgrep \<g:\A, I found this is documented under :help internal-variables:

There are several name spaces for variables.  Which one is to be used is
specified by what is prepended:

        (nothing) In a function: local to a function; otherwise: global
|buffer-variable|    b:   Local to the current buffer.
|window-variable|    w:   Local to the current window.
|tabpage-variable|   t:   Local to the current tab page.
|global-variable|    g:   Global.
|local-variable|     l:   Local to a function.
|script-variable|    s:   Local to a |:source|'ed Vim script.
|function-argument|  a:   Function argument (only inside a function).
|vim-variable|       v:   Global, predefined by Vim.

The scope name by itself can be used as a |Dictionary|.  For example, to
delete all script-local variables: >
    :for k in keys(s:)
    :    unlet s:[k]
  • Oh wow, I was staring at that very page and somehow overlooked The scope name by itself can be used as a Dictionary. Thanks!
    – ivan
    Jul 8, 2017 at 17:43

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.