Search code examples
vimvim-pluginvimdiff

vim: disable plugin by default (diffchar)


Recently (vimdiff: force line-by-line comparison (ignore supposedly missing/additional lines) ), I've found the quite useful vim plugin diffchar, which improves vimdiff by showing multiple diffs on the same line separated, instead of highlighting the whole area from the first to the last diff.

The problem is that I frequently encounter files where diffchar doesn't work properly, namely spills out a whole lot of errors when vimdiff is opened, plus I think it slows down vimdiff substantially for large files (which I'm dealing with far too often).

Is there a way to disable this (or any) plugin by default?

The plugin already has the functionality to turn it off (toggle it), mapped to F7. What I'd like is that it's turned off by default, but that I'm still able to turn it on (using F7) when I specifically need it. (I'm also fine with tweaking the source file of the plugin accordingly, BTW.) What I've already tried is simply adding the command F7 is mapped to (ToggleDiffCharAllLines) to .vimrc, but this doesn't work.


Solution

  • Just put this into your ~/.vimrc:

    let g:DiffExpr = 0
    

    You then have to explicitly enable the plugin via one of its mappings or commands.