[英]Vim Normal Background Changing Foreground Text Color
I'm trying to standardize terminal colors in my vim
theme and I came across some odd behavior about how Vim appears to handle foreground text color depending on background colors. 我试图在我的
vim
主题中标准化终端颜色,并且遇到了一些奇怪的现象,关于Vim如何根据背景颜色来处理前景文本颜色。
Consider this very simple vim
theme: 考虑一下这个非常简单的
vim
主题:
if exists("syntax_on")
syntax reset
endif
set t_Co=256
highlight Normal ctermfg=NONE ctermbg=234 cterm=NONE
highlight PreProc ctermfg=197 ctermbg=NONE cterm=NONE
It's not very pretty (as a simple example) but it looks like this: 它不是很漂亮(作为一个简单示例),但是看起来像这样:
If I then change one line setting Normal
to ctermbg=NONE
like so: 如果我然后将“
Normal
设置为ctermbg=NONE
则更改一行, ctermbg=NONE
所示:
highlight Normal ctermfg=NONE ctermbg=NONE cterm=NONE
I get something that looks like this: 我得到的东西看起来像这样:
As you can see, the background clearly changes (as expected), but the foreground color changes as well. 如您所见,背景明显改变(如预期),但前景颜色也改变。
Why is changing this property in vim
causing this behavior? 为什么在
vim
更改此属性会导致此行为? How can I remove the background without changing the foreground colors? 如何在不更改前景色的情况下删除背景?
I'm using the default terminal in OS X with 256 bit color enabled. 我正在OS X中使用启用256位颜色的默认终端。
I appreciate the help! 感谢您的帮助!
That behavior is normal, expected, and explained in :hi-normal-cterm
. 该行为是正常的,预期的,并在
:hi-normal-cterm
。
Basically, the value of the background
option is used to define a bunch of default colors for different highlight groups and that option is redefined whenever you change the Normal
highlight group. 基本上,
background
选项的值用于为不同的突出显示组定义一堆默认颜色,并且每当更改“ Normal
突出显示组时都会重新定义该选项。
To force a value for background
, add this line to your colorscheme: 要强制设置
background
值,请将此行添加到您的colorcheme中:
set background=dark
or: 要么:
set background=light
Also, there's no reason whatsoever to put set t_Co=256
anywhere in any vim script. 另外,没有理由将
set t_Co=256
放在任何vim脚本中的任何地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.