如何强制 vim 拼写检查器忽略 lowercase/uppercase 错误
How to force vim spellchecker to ignore lowercase/uppercase errors
我发现 here and here 如何强制 Vim 拼写检查器忽略大写字母的单词,使其不被检查。但我的情况恰恰相反。我想忽略以更正形式包含大写字母的单词。
所以在句子中:
欧洲最佳
只有单词 chozen 是错误的。
如何实现?
感谢任何提示。
此答案由 Rich on vi&vim stackexchange 最先发布:
I don't think that Vim has a setting for this. One workaround is to
create a new spellfile that contains everything in your current spell
file(s) but with lowercase letters only:
Create a new buffer containing everything from the spell file(s) currently in use:
:spelldump
Delete lines that don't contain any upper-case characters. This isn't strictly necessary, but there's no point keeping duplicate
entries for lower-case words:
:v/\u/d
Convert the entire file to lower-case, ignoring lines that contain the locations of the spell files:
:v/^#/norm gu$
Save the file:
:w ~/.vim/spell/lowercase.utf-8.add
Start using this file in addition to the standard files in Vim's $VIMRUNTIME
directory. Note that Vim uses a default 'spellfile'
value internally if the setting is empty, so if you already have any
existing spell files, you will need to ensure that they are included
in this setting (which accepts a comma-delimited list):
:set spellfile=~/.vim/spell/lowercase.utf-8.add
Note that if you set this option in a running instance of Vim, it
doesn't seem to take effect for spell-checking until you interact with
it (by, e.g. using the zg
command.)
The above doesn't affect the way that Vim detects lower-case words at
the start of a sentence as spelled incorrectly. You can disable this
with the 'spellcapcheck'
option:
:set spellcapcheck=
我发现 here and here 如何强制 Vim 拼写检查器忽略大写字母的单词,使其不被检查。但我的情况恰恰相反。我想忽略以更正形式包含大写字母的单词。
所以在句子中:
欧洲最佳
只有单词 chozen 是错误的。
如何实现?
感谢任何提示。
此答案由 Rich on vi&vim stackexchange 最先发布:
I don't think that Vim has a setting for this. One workaround is to create a new spellfile that contains everything in your current spell file(s) but with lowercase letters only:
Create a new buffer containing everything from the spell file(s) currently in use:
:spelldump
Delete lines that don't contain any upper-case characters. This isn't strictly necessary, but there's no point keeping duplicate entries for lower-case words:
:v/\u/d
Convert the entire file to lower-case, ignoring lines that contain the locations of the spell files:
:v/^#/norm gu$
Save the file:
:w ~/.vim/spell/lowercase.utf-8.add
Start using this file in addition to the standard files in Vim's
$VIMRUNTIME
directory. Note that Vim uses a default'spellfile'
value internally if the setting is empty, so if you already have any existing spell files, you will need to ensure that they are included in this setting (which accepts a comma-delimited list)::set spellfile=~/.vim/spell/lowercase.utf-8.add
Note that if you set this option in a running instance of Vim, it doesn't seem to take effect for spell-checking until you interact with it (by, e.g. using the
zg
command.)The above doesn't affect the way that Vim detects lower-case words at the start of a sentence as spelled incorrectly. You can disable this with the
'spellcapcheck'
option::set spellcapcheck=