加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何在编写vimscript时使用选项?

发布时间:2020-12-15 21:15:33 所属栏目:安全 来源:网络整理
导读:[求助]似乎解决方案是这样的: if exists('g:nameOfMyOption') g:nameOfMyOption ...endif 这很简单,但我无法在网上找到答案.我想在插件文件中做这样的事情: " MyChecker.vim"" Uncomment the following line to set the autochecker option"set autochecke
[求助]似乎解决方案是这样的:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读