I have a terminal color scheme that makes the default highlighting settings for diffs relatively hard to read. To address this, I’ve added my own custom settings inside of ~/.vim/after/syntax/diff.vim
:
hi diffAdded term=NONE ctermfg=Green
hi diffRemoved term=NONE ctermfg=Red
This works great for git diff
, for example, but the customizations do not apply when I use git commit -v
, so I still get unreadable diffs. I looked in the syntax definition for gitcommit.vim
, and I noticed that it uses syn include
to create a nested region:
" gitcommit.vim
syn include @gitcommitDiff syntax/diff.vim
syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff
Since it looks like it just uses diff.vim
under the hood, I figured that copying my custom styles to ~/.vim/after/syntax/gitcommit.vim
would do the trick:
" identical to diff.vim
hi diffAdded term=NONE ctermfg=Green
hi diffRemoved term=NONE ctermfg=Red
Unfortunately, this doesn’t seem to work—vim still uses the default syntax highlighting.
What’s wrong? How can I customize the syntax highlighting for a region included with syn include
?