Getting gVim vimdiff to ignore case

I am trying to compare two prefabricated files, where each cap was written and the other is lowercase. Many lines are identical for case and space.

I tried the following, and two buffers in diff mode:

:set diffopt+=icase :set diffopt+=iwhite :diffupdate 

The whitespace seems to work well, but the case of ignoring does not do its job. For example, in the following two lines:

  I0=R0; // ADDRESS OF INPUT ARRAY i0 = r0; // address of input array 

[the first line starts with 12 spaces, the second with one tab]

Why? What can I do?

UPDATE: just noticed that in these two lines all the differences were ignored OK:

  // MULTIPLY R1 BY 4 TO FETCH DATA OF WORD LENGTH // multiply r1 by 4 to fetch data of word length 
+8
vim vimdiff ignore-case
source share
2 answers

Your comparison fails because of a space, not because of this. This is because when you use the iwhite parameter, in the background, vimdiff runs diff -b , which is more limiting on how it compares spaces than what you are looking for. More specifically, the -b option ignores differences in the number of spaces where spaces already exist . In your example, i0 = r0; marked as different from I0=R0; , because in it there are no spaces between characters, and the other is not.

According to the vimdiff documentation, you can override the default behavior of the iwhite parameter by setting diffexpr to a non-empty value. The diff flag you are interested in is --ignore-all-space , which is more flexible regarding spaces. You can change diffexpr in vimdiff to use this option instead of the -b option by default:

 set diffexpr=MyDiff() function MyDiff() let opt = "" if &diffopt =~ "icase" let opt = opt . "-i " endif if &diffopt =~ "iwhite" let opt = opt . "--ignore-all-space " endif silent execute "!diff -a --binary " . opt . v:fname_in . " " . v:fname_new . \ " > " . v:fname_out endfunction 

See the documentation for more details:

http://vimdoc.sourceforge.net/htmldoc/options.html#%27diffopt%27

+7
source share

The following works well for me:

 vimdiff +"set diffopt+=icase" file_1.txt file_2.txt 
+3
source share

All Articles