Tip: #715 - Ignore whitespace in diff operations
Created: May 10, 2004 16:34 Complexity: basic Author: Rick Herrick Version: 6.0 Karma: 5/4 Imported from: Tip#715
Because I'm kinda anal about readability in my source files, I end up changing the whitespace in them quite a bit. 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
- he 'diffopt'
dwsharp at hotmail , May 11, 2004 7:12