Search code examples
vimdiffvimdiff

Is there a way to configure vimdiff to ignore ALL whitespaces?


I'm using vim -d file1 file2 in order to see the differences between them. This works fine, but I want to ignore whitespace changes - they are irrelevant for source code files.

Vim help states that the following command will do the magic:

set diffopt+=iwhite

But unfortunately, this command only adds -b to diff tool command line, and that only ignores trailing whitespaces. The correct command line key for diff should be -w, to ignore all whitespace changes. But I can't find how to modify the diff command line directly from Vim. Of course I can compile a custom diff, or replace diff with diff.sh, but that looks kinda ugly :(.

Is there a better way to modify how Vim interacts with the diff tool for displaying file differences?


Solution

  • I know it's an antique question but for others like me who didn't know, this is now available:

    :set diffopt+=iwhiteall

    Adds the "-w" flag to the "diff" command if 'diffexpr' is empty.

    See :h 'diffopt'