Hello,

> If you think about it, you find that it is very difficult to define what
> "changed" means.  Diff normally has delete, insert and change operators.
> Applying that to a line of characters you can make a change in an
> unlimited number of ways.  Some define the optimal way to be the one
> that has the lowest number of operators, but that often leads to a weird
> display.  E.g., when comparing "one two three four" with "one three two
> four", what should be highlighted?  Perhaps "wo three" and "hree two",
> because that's the changed part of the text.  Or "two" in both lines, as
> it's deleted and inserted.  Or delete "wo t" and insert "hree t"?

What is the difference between char-diff of two lines and normal diff of two
files having one char at each line? A simple script doing :s/./&^M/g ,
comparing the results and highlighting original lines according to that result
can do the work.

However, I think the base of the problem is elsewhere: you can do the described
comparison only if you can match exacly each line of file 1 to some line of
file 2 (1:1 mapping). If not (for example three lines in file 1 replaced by
seven lines in file 2), how can you tell which line should be compared with
which?

So, in general, this is 2D problem and can't be solved 100%. But this idea of
char-diff can be useful in cases where the amount of changed lines are same in
both actually compared hunks. And I must say I would like it very much in that
cases (comparing various config files etc.).

Milan
--
Milan Vancura, Prague, Czech Republic, Europe

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to