I want to set colorscheme during vimdiff at startup. Note this colorscheme would be different than Vim's colorscheme.
1 Answer
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.
-
I think even using
if &diff | colors foobar |endif
in the vimrc might already work. Aug 28, 2017 at 8:18 -