tags:

views:

363

answers:

2

How do i load a different colorscheme when i do a vimdiff.

I want this because the my current colorscheme does not show some diffs properly in vimdiff like the same fg/bg color for the text. This makes it impossible to understand the diff. So everytime i do a vimdiff i have to do :colorscheme some_other_scheme

Can this be done in .vimrc file?

+4  A: 

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 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.

DataWraith
Is it possible to call more than one command between the two pipes "|"? I would be interested in return to original colorscheme after using vimdiff from vim too...
Somebody still uses you MS-DOS
DataWraith
+1  A: 
Gautam Borad