options - 编写vimscript时如何使用选项?

标签 options vim

[已解决] 看来解决方法是这样的:

if exists('g:nameOfMyOption') && g:nameOfMyOption
     ...
endif

这很简单,但我在网上找不到答案。我想在插件文件中做这样的事情:
" MyChecker.vim
"
" Uncomment the following line to set the autochecker option
"set autochecker=1

if ISSET(autochecker)
   autocmd InsertChange * :call MyAutoCheckerFunction()
endif

我如何做 ISSET 线?我宁愿不必显式设置 autochecker=0,我希望它只检查 autochecker 是否存在。

编辑:当我尝试以下操作时:
if &autochecker == 1
    ...
endif

我收到此错误消息:
Error detected while processing MyChecker.vim:
line   32:
E113: Unknown option: autochecker
E15: Invalid expression: &autochecker == 1

最佳答案

您不能在 vim 中创建自定义选项。您需要创建一个全局变量,而不是:

let g:AutoChecker = 1

....

if g:AutoChecker == 1
   " ...
endif

关于options - 编写vimscript时如何使用选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10016039/

相关文章:

wolfram-mathematica - 我如何获得相互依赖的选项?

python - 在类中的方法内的方法中使用选项(argparse)

python - 在高级功能中访问低级功能选项的清晰方法?

jquery - 从 html 表单下拉选项列表中删除重复值

vim - 当存在水平分割时,如何将垂直分割窗口移动到水平分割?

visual-studio-2010 - 如何切换回那些烦人的水平点和箭头? =)

vim - clang_complete - cc_args.py 不会生成 .clang_complete 文件

arduino - 是否可以在 snipmate 中包含文件中的片段

vim - 选项卡/窗口组移动 : (Ctrl-W)(Ctrl-L), 等

Vim 在插入模式下随机添加新行