I'm using the VCSCommand plugin.
I'm calling VimDiff utility inside Vim by calling :VCSVimDiff
.
I have in my vimrc
:
if &diff
set t_Co=256
set background=dark
colorscheme peaksea
else
colorscheme molokai
endif
It works when I call vimdiff
from my console, but not when I call it from Vim using VCS.
Is this a plugin problem, or a vimrc
config that is missing?
Best Answer
Vim reads your vimrc once, at startup. The
if &diff
statement is executed when it is read, not every time the state of'diff'
changes. One way to have those color commands executed when you execute:VCSVimDiff
is to put them in an autocommand in your vimrc, like this.where the
FilterWritePre
event is one that is triggered when Vim performs a diff.[The comment didn't work well, so I'll add to my original answer.]
If you want to end VimDiff with
:q
, what you could do is set up another autocommand, maybe using theBufWinLeave
event, again testing&diff
and executing the commands to set your default colorscheme.What I do is use the following command to delete the buffer I had diff'd against, turn off diff mode and restore some saved settings.
To make and/or save those settings when diff mode is entered, I use the following autocommands.
Those commands have evolved over the years, which is my excuse for their inconsistencies.