Load different colorscheme when using vimdiff

vim, vimdiff

Solution

If you're calling `vimdiff` from the command-line, put the following in your `.vimrc`:

if &diff
    colorscheme some_other_scheme
endif

(if you're already in vimdiff => `:colorscheme some_other_scheme` thanks dlaehnemann)

If you're using vimdiff from within vim, you'd either have to override the commands you use to start/stop it (e.g. `diffthis`, `diffoff`) using `:cnoreabbr` (there's also a plugin) or use an autocommand:

`au FilterWritePre * if &diff | colorscheme xyz | endif`

FilterWritePre is called before filtering through an external program (the diff utility) and the `&diff`-option is set by vim when it's going into diff-mode (among others, see `:help diff`)

I'm not sure which autocommand to use to return to the original colorscheme though.

Problem

How to load a different colorscheme when doing `vimdiff`. I want this because the my current colorscheme does not show some diffs properly in `vimdiff`, For. eg some diff is shown with same fg/bg color. This makes it very hard to understand the diff. So every time i do a `vimdiff` i have to do `:colorscheme some_other_scheme` Can this be done in `.vimrc` file?

Original source