如何改变vim拼写中的单词识别?
我喜欢 vim 7.0 通过 :setpell 支持拼写检查,而且我喜欢它默认只检查 C 代码中的注释和文本字符串。 但我想找到一种方法来改变行为,以便 vim 知道当我编写包含下划线的单词时,我不希望检查该单词的拼写。
问题是我经常会在注释中引用变量或函数名称,所以现在 vim 认为每一段不是完整正确单词的文本都是拼写错误。 例如。
/* 变量 proj_abc_ptr 用于函数 do_func_stuff' */
大多数时候,下划线分隔的部分是完整的单词,但其他时候它们是缩写,我不希望添加到单词中列表。 有没有全局方法告诉 vim 在拼写检查时将 _ 作为单词的一部分包含在内?
I like that vim 7.0 supports spell checking via :set spell, and I like that it by default only checks comments and text strings in my C code. But I wanted to find a way to change the behavior so that vim will know that when I write words containing underscores, I don't want that word spell checked.
The problem is that I often will refer to variable or function names in my comments, and so right now vim thinks that each piece of text that isn't a complete correct word is a spelling error. Eg.
/* The variable proj_abc_ptr is used in function do_func_stuff' */
Most of the time, the pieces seperated by underscores are complete words, but other times they are abbreviations that I would prefer not to add to a word list. Is there any global way to tell vim to include _'s as part of the word when spell checking?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是一些要放入
.vim/after/syntax/{LANG}.vim
文件中的更通用的拼写检查异常规则:将
pythonComment,python.*String
更改为您的语言。transparent
意味着匹配从包含块继承其突出显示属性(即这些规则不会更改文本的显示方式)。contained
防止这些匹配超出包含块(最后一条规则以\S*
结尾,这可能会匹配超出块的末尾)containedin 保存要添加这些新规则的现有语法组的列表。
contains=@NoSpell
覆盖所有继承的组,从而告诉拼写检查器跳过匹配的文本。Here are some more general spell-checking exception rules to put in
.vim/after/syntax/{LANG}.vim
files:Change
pythonComment,python.*String
for your language.transparent
means that the match inherits its highlighting properties from the containing block (i.e. these rules do not change the way text is displayed).contained
prevents these matches from extending past the containing block (the last rule ends with\S*
which would likely match past the end of a block)containedin
holds a list of existing syntax groups to add these new rules to.contains=@NoSpell
overrides any and all inherited groups, thus telling the spellchecker to skip the matched text.您需要将其移至其自己的组中。 像这样的事情:
在某些荧光笔中,您可能需要在匹配行末尾使用
contains=@NoSpell
,但在 C 中,默认值为@NoSpell
,所以应该是就这样就好了。You'll need to move it into its own group. Something like this:
In some highlighters you may need
contains=@NoSpell
on the end of the match line, but in C, the default is@NoSpell
, so it should be fine like that.