English 中文(简体)
如何在撰写文字时使用各种选择?
原标题:How to use options when writing vimscript?
  • 时间:2012-04-04 17:11:15
  •  标签:
  • vim

它非常简单,但我无法在线找到答案。 在原始档案中,我想做这样的事情:

" MyChecker.vim
"
" Uncomment the following line to set the autochecker option
"set autochecker=1

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

我怎么办? 我不必明确设置汽车机车=0,我喜欢在汽车机车存在时进行检查。

Edit: When I try the following:

if &autochecker == 1
    ...
endif

我收到这一错误信息:

Error detected while processing MyChecker.vim:
line   32:
E113: Unknown option: autochecker
E15: Invalid expression: &autochecker == 1
最佳回答

你们可以自行制定习俗选择。 你们需要创造全球变量,而不是:

let g:AutoChecker = 1

....

if g:AutoChecker == 1
   " ...
endif
问题回答

For general options, I use the following function: lh#option#get(). It first searches if b:{varname} exists to return its value, then g:{varname}. Otherwise the default value provided is returned if none of the variables exist.

关于与方案有关的备选办法(即,具体卷宗类型中的备选办法可以压倒一切),我使用另一个功能:

<C++ Options section of lh-cpp/a>文件间接解释了这两项职能的理由。

(回答问题部分)。

解决办法似乎是:

if exists( g:nameOfMyOption ) && g:nameOfMyOption

     ...

endif




相关问题
Autoupdate VIM Plugins?

Is it possible to update vim plugins automatically?

how to unindent in vim without leaving edit mode?

I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

Vim - Deleting XML Comments

How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...

Profiling Vim startup time

I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...

热门标签