How do I inspect Vim variables?

VariablesVim

Variables Problem Overview


In .vimrc, there are several lines that look like:

let g:SuperTabDefaultCompletionType="<c-x><c-o>"

How do I inspect them inside Vim? Something to this effect:

:echom &g:SuperTabDefaultCompletionType

But that command results in an error:

E113: Unknown option: SuperTabDefaultCompletionType
E15: Invalid expression: &g:SuperTabDefaultCompletionType

How do I inspect these kinds of variables in Vim? Some plugins set some defaults which I need to inspect.

Variables Solutions


Solution 1 - Variables

:echo g:SuperTabDefaultCompletionType

works fine. It gives an error if the variable isn't defined.

Solution 2 - Variables

Like lucapette wrote you can use :echo g:foo to inspect a variable. You can also use :let to see all defined variables and their values.

Solution 3 - Variables

See if this helps: http://learnvimscriptthehardway.stevelosh.com/chapters/19.html. Should give you some insight on how vim variables work, and you can check out chapter 20 as well if you have any difficulties inspecting them due to scope issues.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKitView Question on Stackoverflow
Solution 1 - VariableslucapetteView Answer on Stackoverflow
Solution 2 - VariablesbetaView Answer on Stackoverflow
Solution 3 - VariablesjlemosView Answer on Stackoverflow