created May 10, 2004 · complexity basic · author Rick Herrick · version 6.0
I often change the whitespace in my programs to make them more readable. For example, I like var declarations to line up, so I have things like:
private static final String SOME_VAR1 = "This is a var";
private static final String[] SOME_VAR2 = { "This is a var", "This is a var", "This is a var" };
If I add something that pushes the tab over one, then all these lines get an extra tab stuck in there, meaning that the lines show up as changed in the default Vim set up.
To make this not so, add the "w" command-line option to the MyDiff() function in your vimrc file. This file is like in either C:\Vim\Vim62 or C:\Program Files\Vim\Vim62 (if it's not, you should be clever enough to figure out where it is :^). The default diff call in that function looks like this:
silent execute '!C:\Vim\vim62\diff -a ' . opt . '"' . v:fname_in . '" "' . v:fname_new . '" > "' . v:fname_out . '"'
Just change this to look like this:
silent execute '!C:\Vim\vim62\diff -aw ' . opt . '"' . v:fname_in . '" "' . v:fname_new . '" > "' . v:fname_out . '"'
Just that one option change can make a world of difference!
Comments
With the 'diffopt' option, you can change how Vim processes diffs without having to change the MyDiff() function. For example, to ignore whitespace in the diff, you can use
set diffopt+=iwhite
You can issue this command while viewing a diff to update the view dynamically (may need to be followed by a :diffupdate command), or you can add the command to your vimrc to have it always in effect. Note: the iwhite parameter adds the -b option instead of the -w option, so if you really want -w, you will have to use the method in the tip above. For more information on the option, see