如何检查 Vim 变量?

.vimrc中,有几条线看起来像:

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

我如何在 Vim 里面检查它们? 大概是这样的:

:echom &g:SuperTabDefaultCompletionType

但是这个命令会导致一个错误:

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

如何在 Vim 中检查这些类型的变量? 一些插件设置了一些我需要检查的默认值。

66335 次浏览
:echo g:SuperTabDefaultCompletionType

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

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.

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.