include=
的行)。#1 楼
颜色由以下四个突出显示组(:help hl-DiffAdd
)控制:DiffAdd diff mode: Added line
DiffChange diff mode: Changed line
DiffDelete diff mode: Deleted line
DiffText diff mode: Changed text within a changed line
这些通常由配色方案定义,但您可以在
~/.vimrc
中自定义它们( :colorscheme
命令),如果您喜欢整体方案,则不要突出显示差异。只需使用:highlight
重新定义。这是我的个性化定制(对于GVIM;对于终端,您需要/ q以外的其他适当的ctermfg/bg=...
属性):hi DiffAdd gui=none guifg=NONE guibg=#bada9f
hi DiffChange gui=none guifg=NONE guibg=#e5d5ac
hi DiffDelete gui=bold guifg=#ff8080 guibg=#ffb0b0
hi DiffText gui=none guifg=NONE guibg=#8cbee2
如果您要即时切换颜色方案,您需要通过
:hi
重新调用这些:autocmd ColorScheme * hi ...
命令#2 楼
一种快速的解决方法是禁用语法突出显示。有时,代码语法高亮显示将使前景文本与vimdiff背景颜色相同,从而使文本“不可见”。:syntax off
如果要自动对vimdiff执行此操作,然后将其添加到
~/.vimrc
的末尾:if &diff
syntax off
endif
#3 楼
将Ingo Karkat的解决方案扩展到终端,hi DiffAdd ctermfg=NONE ctermbg=Green
hi DiffChange ctermfg=NONE ctermbg=NONE
hi DiffDelete ctermfg=LightBlue ctermbg=Red
hi DiffText ctermfg=Yellow ctermbg=Red
下面是
cterm-colors
,如果要添加首选颜色而不是我使用的颜色。 NR-16 NR-8 COLOR NAME
0 0 Black
1 4 DarkBlue
2 2 DarkGreen
3 6 DarkCyan
4 1 DarkRed
5 5 DarkMagenta
6 3 Brown, DarkYellow
7 7 LightGray, LightGrey, Gray, Grey
8 0* DarkGray, DarkGrey
9 4* Blue, LightBlue
10 2* Green, LightGreen
11 6* Cyan, LightCyan
12 1* Red, LightRed
13 5* Magenta, LightMagenta
14 3* Yellow, LightYellow
15 7* White
评论
Neovim用户的注释混淆了为什么这些高亮组不起作用的原因,您必须使用diffAdded,diffChanged和diffRemoved。不知道DiffText的nvim替代方案是什么-也许diffLine?
–J.M. Janzen
20-4-28下午14:07