我不明白如何在终端 vim 中获得“正确”的颜色。我的.vimrc
文件如下所示:
syntax enable
colorscheme desert256
我在 Mac OS X Lion 的终端上以黑色背景执行此操作。但是当我执行 vim 时,我得到了颜色,但我注意到它set background=light
应该是深色的(vim 似乎总是猜错背景)。所以如果我执行 a ,set background=dark
颜色会改变,但如果我输入colorscheme
,vim 会报告我回到默认设置。
我应该使用syntax on
或其他命令吗?
请提供一些关于如何在终端 vim 中正确进行语法高亮的指导。
答案1
从 中找到此片段zenburn.vim
。
" * Work-around to a Vim bug, it seems to misinterpret ctermfg and 234 and 237
" as light values, and sets background to light for some people. If you have
" this problem, use:
" let g:zenburn_force_dark_Background = 1
if exists("g:zenburn_force_dark_Background")
" Force dark background, because of a bug in VIM: VIM sets background
" automatically during "hi Normal ctermfg=X"; it misinterprets the high
" value (234 or 237 above) as a light color, and wrongly sets background to
" light. See ":help highlight" for details.
set background=dark
endif
要解决这个问题,只需添加
set background=dark
desert256.vim
到全部突出显示之后的末尾。