如何更改 Vim 拼写检查中的突出显示样式?
现在,当我在 Vim 中执行 :setpell
时,我会突出显示拼写错误,就像它们是选定的文本一样。我想要的是一个类似 MS-Word 的拼写错误下划线。我尝试查找 :helppell
但找不到线索。任何帮助表示赞赏。
Right now, when I do :set spell
in my Vim, I get spelling errors highlighted as if they are selected text. What I want is an MS-Word like underlining of spelling errors. I tried to lookup :help spell
but could not find a clue. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
SpellBad
突出显示组突出显示拼写错误。为了让它按照你想要的方式突出显示,你应该在 vimrc 中改变颜色方案的最后一行之后添加类似的内容(它是
set background=(dark|light)
或colorscheme {方案名称}
)。另请参阅
:h hl-SpellBad
了解其他 Spell* 高亮组的名称和说明。Spelling errors are highlighted using the
SpellBad
highlighting group. To get it highlighted as you want, you should put something likeafter the last line that is altering the color scheme in your vimrc (it is either
set background=(dark|light)
orcolorscheme {schemename}
).See also
:h hl-SpellBad
for names and descriptions of other Spell* highlight groups.每次设置颜色方案时都需要输入以上内容。如果您想避免它,您应该使用
autocmd
。请参阅 https://vi.stackexchange.com /questions/18295/如何设置仍然显示拼写错误的颜色方案
The above needs to be typed everytime you set colorscheme. If you wish to avoid it, you should use
autocmd
.See https://vi.stackexchange.com/questions/18295/how-to-set-a-colorscheme-that-still-shows-spelling-errors
如果您加载了颜色方案,则更改突出显示颜色的快速而肮脏的方法是修改您的颜色方案。
运行时,
:verbosehighlight SpellBad
显示了我的主题的配置文件所在的位置。更像是,它显示了 SpellBad 指令的设置位置。您的里程可能会有所不同。请参阅下面的输出:我导航到
desert.vim
并添加了hi SpellBad term=reverse ctermbg=226 gui=undercurl guisp=Yellow1
并保存了文件。 (您需要 sudo 来修改文件)。当我重新打开 vim 并运行:verbosehighlight SpellBad
时,输出现在是:我的突出显示颜色已更改!请注意,如果更改颜色方案,您很可能必须更改所选颜色方案文件中的突出显示颜色。
For a quick and dirty way to change the highlighting color if you have a colorscheme loaded, is to modify your colorscheme.
Running,
:verbose highlight SpellBad
showed me where the config file is for my theme. More like, it showed where the SpellBad directive was set. Your mileage may vary. Please see below output:I navigated to
desert.vim
and added,hi SpellBad term=reverse ctermbg=226 gui=undercurl guisp=Yellow1
and saved the file. (you'll need sudo to modify the file). Once I reopened vim and ran,:verbose highlight SpellBad
the output was now:My highlight color was changed! Note that if you change your colorscheme, you'll most likely have to change the highlight color in your selected colorscheme file.