3

Is there any way to list all global variable? I'm guessing i could maintain a list where multiple value represent a global variable but that feel a bit weird. is there an official way to do that? (looked into the docs but didn't find anything)

I'm only talking about g:variable_name here.

Nordine Lotfi
  • 683
  • 4
  • 16
  • hmm, didn't found that when I searched -- anyway, looked at the two answer there, and yes they do answer this question too, but given the two answer there aren't repeated there, I wonder: should I accept this as duplicate or not? (especially since it's mostly about global variable, but I guess you can apply it to other variable type) @statox – Nordine Lotfi Mar 14 '22 at 19:09
  • 1
    If you are not sure you can let the community decide: Your question should now appear in the close votes queue if enough people think it's a duplicate it will be closed as so and otherwise it will stay open. It's not super important anyway now that both questions are linked it might be useful for future readers. – statox Mar 14 '22 at 20:15
  • you're right :) Thanks for the clarification @statox – Nordine Lotfi Mar 14 '22 at 20:20

2 Answers2

6

This command will list all global variables:

:let g:

Using :let by itself will list all variables, and passing it just a prefix (such as g: or b: or v:) will filter the output to only include variables in that prefix. Therefore, :let g: will show you all global variables.

filbranden
  • 28,785
  • 3
  • 26
  • 71
3

I tend to use :echo keys(g:) as g: is the directory used to store global variables.

Luc Hermitte
  • 17,351
  • 1
  • 33
  • 49