# Vscode: how to generate a list of all variables used in code?

**URL:** <https://discourse.julialang.org/t/vscode-how-to-generate-a-list-of-all-variables-used-in-code/61267>\
**Category:** VS Code\
**Tags:** documentation, documenter, vscode\
**Created:** [May 16, 2021, 11:07pm UTC](https://discourse.julialang.org/t/vscode-how-to-generate-a-list-of-all-variables-used-in-code/61267 "2021-05-16T23:07:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [May 16, 2021, 11:07pm UTC](https://discourse.julialang.org/t/vscode-how-to-generate-a-list-of-all-variables-used-in-code/61267/1 "2021-05-16T23:07:41Z")

</div>

Hallo, I am starting to document a large program [SoilWater-ToolBox](https://github.com/joseph-pollacco/SoilWater-ToolBox), is there a way to generate a list of the all the variables used in the program ?

I am using Documenter[Documenter.jl](https://github.com/JuliaDocs/Documenter.jl)

Many thanks for any help you may provide 😀

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [May 17, 2021, 12:28am UTC](https://discourse.julialang.org/t/vscode-how-to-generate-a-list-of-all-variables-used-in-code/61267/2 "2021-05-17T00:28:34Z")

</div>

All variables? I don’t think that is possible, because variables can have different labels in the same program.

The constant can be documented with:

```julia
julia> """
       speed of light
       """
       const c = 300_000
c

help?> c
search: c cp cd csc cot cos cmp cld cis cat csch cscd coth cotd cosh cosd cosc copy conj chop ceil cbrt Cmd ccall const catch Char

  speed of light

julia>

```

as any other function. And a “help.md” file with (or put the command below in any other file of the docs):

```julia
# Help entries

'''@autodocs
Modules=[PackageName]
'''

```

(the above ticks should be back-ticks)

will generate the entries of all those commented functions or constants in your manual.

---

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [May 27, 2021, 7:44am UTC](https://discourse.julialang.org/t/vscode-how-to-generate-a-list-of-all-variables-used-in-code/61267/3 "2021-05-27T07:44:09Z")

</div>

Thanks, that is really helpful.

So therefore there is no automatic function which could derive a list of all the variables used in the code.

May be VScode could provide a list of all the variables used in the program as in the **outline** panel.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 27, 2021, 8:02am UTC](https://discourse.julialang.org/t/vscode-how-to-generate-a-list-of-all-variables-used-in-code/61267/4 "2021-05-27T08:02:18Z")

</div>

Can’t you just use `names` here?

---

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [May 27, 2021, 8:03am UTC](https://discourse.julialang.org/t/vscode-how-to-generate-a-list-of-all-variables-used-in-code/61267/5 "2021-05-27T08:03:38Z")

</div>

My code is a huge hydrological model so I want to generate the names so I can document them in the documents.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 27, 2021, 8:09am UTC](https://discourse.julialang.org/t/vscode-how-to-generate-a-list-of-all-variables-used-in-code/61267/6 "2021-05-27T08:09:51Z")

</div>

Right, I meant the `names` function:

```julia
julia> module Foo
       const c = 3
       x() = c
       end
Main.Foo

julia> names(Foo, all=true)
8-element Array{Symbol,1}:
 Symbol("#eval")   
 Symbol("#include")
 Symbol("#x")      
 :Foo              
 :c                
 :eval             
 :include          
 :x     

```

Just need to filter out unneeded/auto-generated symbols.
