molokai
molokai copied to clipboard
Diff lines added/removed aren't green/red
I'm used to viewing diffs of files where added lines are green, and removed lines are red. This is the output of git diff
:
When viewing such diffs with the Molokai theme, added lines are orange, while removed lines are cyan. This is the output of vim temp.diff
:
I've been trying to mess around with the Molokai settings to get the output to look more like what I have for git diff
, especially in regard to the green/red colors of added/removed lines. In particular, I tried setting the following to Red
:
-
Line 43:
-
Original
hi DiffDelete guifg=#960050 guibg=#1E0010
-
Modified
hi DiffDelete guifg=Red guibg=#1E0010
-
-
Line 160:
-
Original
hi DiffDelete ctermfg=162 ctermbg=53
-
Modified
hi DiffDelete ctermfg=Red ctermbg=53
-
Unfortunately, the changes didn't seem to do anything. Is there anything I can do to change the diff colors to be what I want?
I have the same problem. Red / green colour are a must. Has anyone figured this out already?
you must perform the :hi
calls in a colorscheme
autocmd, otherwise the colorscheme will overwrite your :hi
settings. Here's what I use: https://github.com/justinmk/config/blob/master/.vimrc#L587-L607
@justinmk, hmm... I've copied and pasted your snippet, but nothing really happens... :disappointed_relieved:

How can I debug this? Can it also be incorporated into the main colour scheme, with a PR? I think it's a must!
You need to add the snippet to your vimrc and then restart vim...
:neutral_face: that's what I did... The right file is my ~/.vimrc
, and yes, I've relaunched Vim.

This is basic functionality. Ask on vi.stackexchange.com if you need help.
@justinmk, you can try yourself. Make a ~/.vimrc
with the code you pointed out and have the file ~/.vim/colors/molokai.vim
. Try to see a diff and taa-daa, it does not work.
Here's my ~/.vimrc
, you can source it with vim -u test_vimrc
.
As you suggested, I've created a question on vi@stackexchange.
@coldhawaiian, here is the solution. Put these lines in your ~/.vimrc
colorscheme molokai
" Better gitcommit messages
hi diffAdded ctermbg=NONE ctermfg=46 cterm=NONE guibg=NONE guifg=#00FF00 gui=NONE
hi diffRemoved ctermbg=NONE ctermfg=196 cterm=NONE guibg=NONE guifg=#FF0000 gui=NONE
hi link diffLine String
hi link diffSubname Normal
And here a before / after :grimacing:

My mistake. Molokai should not use those colors though.
@justinmk, to which colours are you referring?
Moreover, in the solution I've suggested there is no need of the autocmd
and it looks more simple. Or this won't work in some specific conditions for which you've chosen to use the autocmd
?
I'm saying molokai should not change its colors. Removing personality defeats the purpose of a colorscheme.
@justinmk, if you use git then vim has to show git's diff colours, whatever colour scheme you have. Having the light blue and orange for removal and addition are completely deceiving, at least personally speaking. And I believe I'm not the only one of this opinion. But then, taste is subjective.
git config color.diff.old
, git config color.diff.new
, may be configured to have any color. It might be an interesting feature for the Vim ftplugin for git
to detect that configuration and set colors in a ft=git
buffer, optionally. It's not the realm of a colorscheme though.
Thanks, @Atcold. This was enough for me:
colo molokai
hi diffAdded ctermfg=46 cterm=NONE guifg=#2BFF2B gui=NONE
hi diffRemoved ctermfg=196 cterm=NONE guifg=#FF2B2B gui=NONE
(A little lighter than pure red/green fits better with the theme IMHO.)