# vimdiff mergetool diff mode detection in vimrc broken by commit 0041797449

2 messages from 2022-07-12 to 2022-07-12. Participants: Andrew Oates, Fernando Ramos.
Thread: https://gitlist.dev/t/58139

## Andrew Oates, 2022-07-12 00:06

Subject: vimdiff mergetool diff mode detection in vimrc broken by commit 0041797449
Message-ID: <CAAVLcG42wom6Rf=6YZoc+iUnXDxshBfGOjqQPryGkzXxRxb-hA@mail.gmail.com>
URL: https://gitlist.dev/e/CAAVLcG42wom6Rf%3D6YZoc%2BiUnXDxshBfGOjqQPryGkzXxRxb-hA%40mail.gmail.com

```
Hi all,

I believe commit 0041797449da61f4131bb1673fa5d4c3af48240d ("vimdiff:
new implementation with layout support") broke the ability to detect
diff mode in a .vimrc, because it removed '-d' from the command line
use to invoke vim ('&diff' evaluates to false, because diffmode isn't
enabled until the commands are run, which happens _after_ vimrc is
executed AFAICT).  I check &diff in my vimrc to set various settings
specifically when doing a diff/merge.

Just adding '-d' back breaks the layouts unfortunately. I can hack
around this with a heuristic that looks for a mergetool-like
invocation, but ideally there would be a way to set the canonical diff
setting correctly.  It may be as simple as adding some extra commands
to close the extra windows opened by adding '-d'.

Thoughts?

Cheers,
Andrew

```

## Fernando Ramos, 2022-07-12 05:56

Subject: Re: vimdiff mergetool diff mode detection in vimrc broken by commit 0041797449
Message-ID: <Ys0NBXe76q6Ls6OI@zacax395.localdomain>
URL: https://gitlist.dev/e/Ys0NBXe76q6Ls6OI%40zacax395.localdomain
In-Reply-To: <CAAVLcG42wom6Rf=6YZoc+iUnXDxshBfGOjqQPryGkzXxRxb-hA@mail.gmail.com>

```
> I check &diff in my vimrc to set various settings specifically when doing a
> diff/merge.

Hi Andrew, could using an auto command on the "DiffUpdated" event work for you?

Example: add this to .vimrc:

    au DiffUpdated * if &diff | colorscheme darkblue | endif

This function will be executed every time "diff mode" is updated in any way and
seems to work both when running vimdiff directly and when entering diff mode
interactively (as it is the case now when running "git mergetool").

It has the added benefit that you can also use this same "trick" to toggle the
settings off when *exiting* diff mode:

    au DiffUpdated * if !&diff | colorscheme desert | endif

Let me know if this is enough for your use case.

Thanks!


```
