Tuesday, July 8, 2014

Re: vimdiff case insensitive

2014-07-03 21:05 GMT+0200, Christian Brabandt <cblists@256bit.org>:
> Hi marco!
>
> On Do, 03 Jul 2014, marco restelli wrote:
>
>> 2014-07-03 11:40 GMT+0200, Christian Brabandt <cblists@256bit.org>:
>> > Am 2014-07-03 11:18, schrieb marco restelli:
>> >> 2014-07-03 11:08 GMT+0200, marco restelli <mrestelli@gmail.com>:
>> >>> 2014-07-03 10:58 GMT+0200, marco restelli <mrestelli@gmail.com>:
>> >>>> Hi all,
>> >>>> this seems a simple question but I can not find any reference: is
>> >>>> it possible to have a case insensitive comparison with vimdiff?
>> >>>
>> >>> OK, I think it is
>> >>>
>> >>> set diffopt+=icase
>> >>
>> >> Sorry for keeping replying to my own thread, but now there is another
>> >> detail that I don't understand. Consider the following example, having
>> >> set diffopt=filler,icase:
>> >>
>> >> 1) if I have two buffers with one line each:
>> >> buffer 1 -> abc this IS a TEST
>> >> buffer 2 -> this IS a TEST
>> >>
>> >> the characters abc in buffer 1 are highlighted (this is what I would
>> >> expect)
>> >>
>> >> 2) same two buffers, with
>> >> buffer 1 -> abc this IS a TEST
>> >> buffer 2 -> this is a test
>> >>
>> >> now the complete lines are highlighted in both buffers, while I would
>> >> like to have highlighted only abc, as in the first case.
>> >>
>> >> Is it possible to have 2) behave exactly like 1), highlighting only
>> >> abs, regardless of the case of the remaining words?
>> >
>> > This is probably caused by the diff command detecting it as 1 deleted
>> > line
>> > and 1 added line instead of 1 changed line.
>> >
>> > I don't think, there is much Vim can do here.
>>
>> OK, thank you Christian, then I think the best solution is to copy the
>> two files, pass both of them to lowercase with u in visual mode and
>> use the standard diff.
>
> If you don't mind changing your buffer, create a custom filterwritepre
> command that filters your buffer through tr (works only on unix or
> within a cygwin environment, e.g. something like this:
>
> fu! ConvertLower()
> %!tr "[A-Z]" "[a-z]"
> endfu
>
> aug MyDiff
> au!
> au FilterWritePre file* call ConvertLower()
> aug end
>
> Adjust the pattern file* to your filenames. If you are on windows,
> replace the tr part by
> :%s/.*/\L&/

Hi Christian, yes, this works, thanks!

Marco

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: