I want to set colorscheme during vimdiff at startup. Note this colorscheme would be different than Vim's colorscheme.

1 Answer 1


You can use an auto command to achieve this:

augroup VimDiff
    autocmd VimEnter,FilterWritePre * if &diff | colorscheme default | endif
augroup END

I found FileWritePre in the thread Diff mode only mappings. This event allows you to enable specific settings after Vim started and when diff mode is set, with :diffthis for example.

If you want to check only once (for vim -d), VimEnter is enough but you should get rid of the auto command altogether (as Christian pointed out):

if &diff
    " setup for diff mode
    " setup for non-diff mode

Read :h diff for more details.

  • I think even using if &diff | colors foobar |endif in the vimrc might already work. Aug 28, 2017 at 8:18
  • Edited with both solutions :)
    – LEI
    Aug 30, 2017 at 14:53

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.