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=).
- Just setting 'xterm 256 color' option in terminal will make the colors look better.balki– balki2023-06-23 14:22:33 +00:00Commented Jun 23, 2023 at 14:22
- @balki Is that some setting I can universally set on the command line or is this different for every terminal emulator? I use Mac, Linux and WSL2oligofren– oligofren2023-06-26 08:29:25 +00:00Commented Jun 26, 2023 at 8:29
6 Answers
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 ...
- 7A note for Neovim users confused why these highlight groups aren't working, you have to use
diffAdded,diffChanged, anddiffRemoved. Not sure what the nvim alternative toDiffTextis - maybediffLine?J.M. Janzen– J.M. Janzen2020-04-28 14:07:53 +00:00Commented Apr 28, 2020 at 14:07
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 - Simple and useful, thanks a lot, works like a charm!SRG– SRG2021-03-04 14:51:49 +00:00Commented Mar 4, 2021 at 14:51
- This does not work for me.oarfish– oarfish2022-04-19 08:56:41 +00:00Commented Apr 19, 2022 at 8:56
- 1Thanks so much, and +1! Had no clue why I couldn't see text that I definitely knew to be there until I switched
:syntax off.Binarus– Binarus2022-11-20 10:07:51 +00:00Commented Nov 20, 2022 at 10:07 - 2best answer, no need for too much work and if I
git mergetoolwithvim, I don't need syntax highlighting!polynomial_donut– polynomial_donut2023-03-24 21:50:16 +00:00Commented Mar 24, 2023 at 21:50
Extending Ingo Karkat's solution to terminal,
hi DiffAdd ctermfg=NONE ctermbg=Green hi DiffChange ctermfg=NONE ctermbg=NONE hi DiffDelete ctermfg=LightBlue ctermbg=Red hi DiffText ctermfg=Yellow ctermbg=Red Below are the cterm-colors, if you want to add your preferred color instead of the ones I used.
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 - 3this was so helpful I wish there was a +10 voting buttonCervEd– CervEd2021-05-22 13:31:43 +00:00Commented May 22, 2021 at 13:31
Another quick (perhaps even lazy) fix is to just do something like:
:colo desert This will change your color scheme, and in some cases will make hidden text become visible.
- 2Welcome to Vi and Vim!D. Ben Knoble– D. Ben Knoble2021-03-22 13:53:15 +00:00Commented Mar 22, 2021 at 13:53
- 2That was the hint I was looking for.ThomasH– ThomasH2022-01-26 14:23:29 +00:00Commented Jan 26, 2022 at 14:23
- 1
:colois short for:colorscheme. To get a list of available colour schemes other thandesert, see stackoverflow.com/q/7331940/247696Flimm– Flimm2022-07-13 08:50:33 +00:00Commented Jul 13, 2022 at 8:50 - 3To add a bit at this 'lazy' solution: Enter
:colothen do TAB as many times as you want to see & test all possible schemes. My favorite dark theme isindustry, and light theme:shineDéjà vu– Déjà vu2023-03-16 08:34:53 +00:00Commented Mar 16, 2023 at 8:34
Accepted answer didn't work for me. I'm using vim 8.2. Add to .vimrc after 'colorscheme ...'
colorscheme challenger_deep " Diff colors (Stand with Ukraine). hi DiffAdded ctermfg=Yellow ctermbg=NONE hi DiffRemoved ctermfg=Blue ctermbg=NONE Changes against accepted answer:
- 'DiffAdded' instead of 'DiffAdd',
- 'DiffRemoved' instead of 'DiffDelete',
- Added in Yellow and remove in Blue.
- Color scheme: https://github.com/challenger-deep-theme/vim
- 1Are you sure this is correct? These names are hard-coded in Vim, and have ever since they're introduced. I can't really see how/why this works, unless that colourscheme does something very odd 🤔Martin Tournoij– Martin Tournoij2023-06-23 14:36:23 +00:00Commented Jun 23, 2023 at 14:36
- @MartinTournoij I'm not sure how it works but it really works in my version of vim. Colorscheme do not add new color groups. Using 'DiffAdd' do not work but 'DiffAdded' works for me.VladSavitsky– VladSavitsky2023-06-24 20:56:05 +00:00Commented Jun 24, 2023 at 20:56
- Do you have a link to your colour scheme?Martin Tournoij– Martin Tournoij2023-06-24 21:03:38 +00:00Commented Jun 24, 2023 at 21:03
- Sure. Here it is: github.com/challenger-deep-theme/vimVladSavitsky– VladSavitsky2023-06-25 06:44:53 +00:00Commented Jun 25, 2023 at 6:44
- Will be interesting to figure out how this worksoligofren– oligofren2023-06-26 08:28:23 +00:00Commented Jun 26, 2023 at 8:28
As per Alan Thompson's answer on SO I personally prefer:
highlight! link DiffText MatchParen or use Todo instead of MatchParen as per the comment there.

