Vim 使用日光化配色方案突出显示 [英] Vim highlighting with solarized color scheme

查看:25
本文介绍了Vim 使用日光化配色方案突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 vim 高亮显示代码中的空白错误:

" 突出显示多余的空格和制表符.突出显示冗余空间 ctermbg=red匹配 RedundantSpaces/\s\+$\|\+\ze\t\|\t/

显示尾随空格问题,如下所示:

但是,我最近开始使用 ;插件页面包含指向替代品的链接.

I have a vim highlight to display whitespace errors in code:

" Highlight redundant whitespaces and tabs.
highlight RedundantSpaces ctermbg=red
match RedundantSpaces /\s\+$\| \+\ze\t\|\t/

Which displays trailing whitespace problems like this:

However, i've recently started using the solarized color scheme and I am not able to get these highlights to display.

I've tried changing the color names to no avail. The relevant part of my (simple) .vimrc says:

syntax enable
set background=dark
colorscheme solarized

解决方案

Moving the :highlight after the :colorscheme still doesn't help you when you switch colorschemes in the Vim session.

For that to work, re-define your highlighting via the ColorScheme event:

autocmd ColorScheme * highlight RedundantSpaces ctermbg=red


BTW, your minimalistic solution has other problems:

  1. It does not highlight in split windows.
  2. You lose the ability of quickly highlighting custom stuff via :match.

There are several plugins that offer this functionality, in a better way. Mine is called ShowTrailingWhitespace; the plugin page contains links to alternatives.

这篇关于Vim 使用日光化配色方案突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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