以下是一些更通用的拼写检查异常规则,可放入.vim/after/syntax/{LANG}.vim
文件中:
" Disable spell-checking of bizarre words:
" - Mixed alpha / numeric
" - Mixed case (starting upper) / All upper
" - Mixed case (starting lower)
" - Contains strange character
syn match spellingException "\<\w*\d[\d\w]*\>" transparent contained containedin=pythonComment,python.*String contains=@NoSpell
syn match spellingException "\<\(\u\l*\)\{2,}\>" transparent contained containedin=pythonComment,python.*String contains=@NoSpell
syn match spellingException "\<\(\l\+\u\+\)\+\l*\>" transparent contained containedin=pythonComment,python.*String contains=@NoSpell
syn match spellingException "\S*[/\\_`]\S*" transparent contained containedin=pythonComment,python.*String contains=@NoSpell
更改pythonComment,python.*String
为您的语言。
transparent
意味着匹配从包含块继承其突出显示属性(即这些规则不会改变文本的显示方式)。
contained
防止这些匹配超出包含块(最后一条规则以\S*
可能匹配超出块末尾的规则结尾)
containedin
包含现有语法组的列表以添加这些新规则。
contains=@NoSpell
覆盖任何和所有继承的组,从而告诉拼写检查器跳过匹配的文本。