如何从 Vim 中的拼写检查中排除大写单词? [英] How to exclude capitalized words from spell checking in Vim?

查看:20
本文介绍了如何从 Vim 中的拼写检查中排除大写单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要添加到字典中的首字母缩略词和专有名词太多.我希望从拼写检查中排除任何包含大写字母的单词.单词由 while 空格或特殊字符(即非字母字符)分隔.这可能吗?

There are too many acronyms and proper nouns to add to the dictionary. I would like any words that contains a capital letter to be excluded from spell checking. Words are delimited by either a whilespace or special characters (i.e., non-alphabetic characters). Is this possible?

当大写单词周围有小写和特殊字符时,答案的第一部分失败:

The first part of the answer fails when the lowercase and special characters surround the capitalized word:

,jQuery,
, iPad,
/demoMRdogood/
[CSS](css)
`appendTo()`,

当小写单词由特殊字符分隔时,当前答案会给出误报(从拼写检查中排除).以下是示例:

The current answer gives false positives (excludes from the spellcheck) when the lowercase words are delimited by a special character. Here are the examples:

(async)
leetcode, eulerproject, 

赏金是给解决这个问题的人的.

The bounty is for the person who fixes this problem.

推荐答案

这是对我有用的解决方案.这通过了我在问题中提到的案例:

Here is the solution that worked for me. This passes the cases I mentioned in the question:

syn match myExCapitalWords +\<\w*[A-Z]\K*\>+ contains=@NoSpell

这是使用 \S 而不是 \K 的替代解决方案.替代解决方案排除括号中的字符并以大写字母开头.由于它更宽松,因此对 URL 更有效:

Here is an alternative solution that uses \S instead of \K. The alternative solution excludes characters that are in the parenthesis and are preceded by a capitalized letter. Since it is more lenient, it works better for URLs:

syn match myExCapitalWords +\<\w*[A-Z]\S*\>+ contains=@NoSpell


排除的"来自拼写检查

无论上述解决方案如何,撇号后的

s 都被视为拼写错误的字母.一个快速的解决方案是将 s 添加到您的字典中或为此添加一个案例:


Exclude "'s" from the spellcheck

s after an apostrophe is considered a misspelled letter regardless of the solution above. a quick solution is to add s to your dictionary or add a case for that:

syn match myExCapitalWords +\<\w*[A-Z]\K*\>\|'s+ contains=@NoSpell

这不是问题的一部分,但这是拼写检查过程的常见情况,所以我在这里提到了它.

This was not part the question, but this is a common case for spell checking process so I mentioned it here.

这篇关于如何从 Vim 中的拼写检查中排除大写单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆