2

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

1

You can use an auto command to achieve this:

augroup VimDiff
    autocmd!
    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
else
    " setup for non-diff mode
endif

Read :h diff for more details.

|improve this answer|||||
  • I think even using if &diff | colors foobar |endif in the vimrc might already work. – Christian Brabandt Aug 28 '17 at 8:18
  • Edited with both solutions :) – LEI Aug 30 '17 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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