The Problem: It's ugly
If you love vimdiff and fugitive then you are probably sick of the terrible color schemes that come default. I've played around with the highlight options a bit but overall I've never been super happy with the outcome. Currently my current vimdiff colorscheme looks like this:
Now I don't know about you but I personally am not a fan of my text being all the same color; I know some people are. So I thought I would do some googling to figure this out but when I tried to google “Vimdiff better highlighting” I didn't come up with much. So here I am trying to make it easier for others to get diff colorscheme of their dreams.
The Solution: All the colors of the rainbow
Well not all of them, just a larger subset. The first part is figuring out how
to change the diff colors. There are 4 main groups at play here and you can set
them to whatever you heart desires with the following in your
highlight DiffAdd cterm=NONE ctermfg=0 ctermbg=2 highlight DiffDelete cterm=NONE ctermfg=0 ctermbg=1 highlight DiffChange cterm=NONE ctermfg=0 ctermbg=6 highlight DiffText cterm=NONE ctermfg=0 ctermbg=6
This will get you something similar to what I had posted in the picture. Notice
how I'm using the cterm prefix, vim has 3 different terminals for highlighting,
term a normal terminal (vt100, xterm) cterm a color terminal (MS-DOS console, color-xterm, these have the "Co" termcap entry) gui the GUI
That's right, were going to be setting this up for a color terminal. If you aren't already using 256 colors in your terminal I suggest you google “How to set up xterm-256color” and get someone more knowledgable to give you advice there. So let's go with the assumption that you have 256 colors and try shaking things up a little bit.
highlight DiffAdd cterm=NONE ctermfg=0 ctermbg=22 highlight DiffDelete cterm=NONE ctermfg=0 ctermbg=52 highlight DiffChange cterm=NONE ctermfg=0 ctermbg=23 highlight DiffText cterm=NONE ctermfg=0 ctermbg=23
But now it's even harder to read and you think I'm crazy but here's where the
magic comes in. How about we stop having black text and we have our regular
colorscheme over the dark background? Just set the
highlight DiffAdd cterm=NONE ctermfg=NONE ctermbg=22 highlight DiffDelete cterm=NONE ctermfg=NONE ctermbg=52 highlight DiffChange cterm=NONE ctermfg=NONE ctermbg=23 highlight DiffText cterm=NONE ctermfg=NONE ctermbg=23
Now were getting somewhere. I still find this a little hard to read somtimes so
I bold the text to make it stand out even more with
highlight DiffAdd cterm=BOLD ctermfg=NONE ctermbg=22 highlight DiffDelete cterm=BOLD ctermfg=NONE ctermbg=52 highlight DiffChange cterm=BOLD ctermfg=NONE ctermbg=23 highlight DiffText cterm=BOLD ctermfg=NONE ctermbg=23
Now this is much better! Hopefully this helps save you some strain when trying to read the diffs.