I have used the following command in Git Bash to perform a 'vimdiff' for 2 XML files.

vimdiff  xml1.xml xml2.xml -c TOhtml -c 'w! result.html' -c 'qa!'

The HTML file which is getting generated is too flashy. The differences are highlighted in Magenta and the background is Black in color. Also the font colors are Cyan and Green. Is there a way to modify the color settings, so that the result file doesn't contain too many bright colors?

Below are the things which I have tried out, but it doesn't give the required result.

  1. Tried changing the 'Foreground' and 'Background' color in the Bash terminal and then performed the vimdiff operation. But the HTML file still contains bright colors.
  2. In Vim I checked for :h :colorscheme, :h :TOhtml, :h :highlight but not sure what exactly should be changed.
  3. I found that most of the sites mention about changing the .vimrc file. I was able to locate the .vimrc file but not sure what changes should be made to the file.

Is there any resolution for the problem?

HTML output:

enter image description here

  • Have you tried editing the HTML to your liking after generation?
    – chicks
    Mar 7, 2018 at 14:02
  • @chicks: Thanks for the response. I can edit the HTML post creation, but I want the entire process to be automated. Hence was looking for solution where in the file will get generated as required. I was able to modify the vimrc file and the required results are being displayed now :-) Mar 8, 2018 at 6:53
  • If you can edit it once to be how you like then it should be straight forward to write a script to do this post-processing step for you. I'm glad you already found a method that works for you.
    – chicks
    Mar 8, 2018 at 13:03

1 Answer 1


As the 2HTML section of help says:

After you save the resulting file, you can view it with any browser. The colors should be exactly the same as you see them in Vim.

So change the color scheme to something you like by calling :colo in your command before TOhtml. Using scheme molokai, for example, you have this:

vimdiff  xml1.xml xml2.xml -c 'colo molokai' -c TOhtml -c 'w! result.html' -c 'qa!'

I've verified that this works.

  • Thanks a lot. I was able to find another way also for getting the desired result. I was able to modify the vimrc file and now the HTML file which is getting generated is in much better reading form :-) Thanks a lot for the response ! Mar 8, 2018 at 6:56
  • @AnitaPradhan No problem. Are you just calling :colo in your vimrc or something else/more?
    – B Layer
    Mar 8, 2018 at 10:59
  • In vimrc file I added the following lines at the end of the file: highlight! link DiffText ToDo highlight DiffAdd cterm=bold ctermfg=White ctermbg=Red gui=bold guifg=White guibg=Red highlight DiffDelete cterm=bold ctermfg=7 ctermbg=1 gui=none guifg=White guibg=Red highlight DiffChange cterm=bold ctermfg=Black ctermbg=White gui=none guifg=Red guibg=White highlight DiffText cterm=bold ctermfg=White ctermbg=Red gui=none guifg=bg guibg=Red Mar 8, 2018 at 12:41
  • After making changes to vimrc, I executed this line: vimdiff xml1.xml xml2.xml -c TOhtml -c 'w! result.html' -c 'qa!'; and the HTML file was in a much readable format. Mar 8, 2018 at 12:44
  • You've almost created a new color scheme except not quite...this could be pretty brittle and/or will probably have negative side effects eventually. You should just put it in a myscheme.vim (for example; choose any name you want) in .vim/colors. You can use an existing scheme from $VIMRUNTIME/colors as a guide. Then put colo myscheme.vim in your vimrc file.
    – B Layer
    Mar 8, 2018 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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