21

I am trying to use vimdiff as my git merge tool, but the colors used are making it unbearable (at least on Windows/Mingw): the background color and the foreground color is the same for some of the conflicting lines, making it needlessly hard to figure out what is going on (see the lines below containing include=).

example

13

The colors are controlled by these four highlight groups (: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

These are typically defined by a color scheme, but you can customize them in your ~/.vimrc (after the :colorscheme command) if you like you scheme overall, just not its diff highlighting. Just redefine using :highlight. Here are my personal customizations (for GVIM; for the terminal you need the appropriate ctermfg/bg=... attributes instead / in addition):

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

If you're switching colorschemes on the fly, you need to re-invoke those :hi commands via :autocmd ColorScheme * hi ...

9

One quick fix is to disable syntax highlighting. Sometimes the code syntax highlighting will cause the foreground text to be the same color as the vimdiff background color, making the text "invisible".

:syntax off

If you want to automatically do this for vimdiff, then add this to the end of your ~/.vimrc:

if &diff
    syntax off
endif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.