When editing documents I always stick to a certain line width of max 80 or 150 characters, depends what I am writing (code, text, etc.). If I change only a little the whole paragraph will shift and hence multiple lines are now in different order to optimal fit for the given line width. How do I diff this to see the actual real change an not the rewrapping artifacts?
Example, textwidth=30:
The actual changes are rather tiny:
The fact that I use (g)vimdiff here is of no matter, if other software can accomplish the desired diff.
Of course software is designed to wrap automatically when text reaches window borders, so I also tried to use just line breaks in the end of a paragraph. The reason why this is not good is, that automatically diffs are line based, and for small changes in paragraphs I get the whole line, meaning then the whole paragraph as diff update :(.
GNU wdiff does a word-by-word diff, not treating spaces and new lines any differently. One can even find vim syntax files for it (e.g. here).
$ cat file1
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Aenean vel molestie
nulla. Pellentesque placerat lacus vel
eros malesuada tristique. Nulla vitae
volutpat justo. Donec est mauris,
$ cat file2
Lorem amet, consectetur adipiscing some
inserted text! elit. Aenean vel molestie
nulla. Pellentesque placerat lacus vel
eros malesuada replacement. Nulla vitae
volutpat justo. Donec est mauris,
$ wdiff file1 file2
Lorem [-ipsum dolor sit-] amet, consectetur
adipiscing {+some inserted text!+} elit. Aenean vel molestie
nulla. Pellentesque placerat lacus vel
eros malesuada [-tristique.-] {+replacement.+} Nulla vitae
volutpat justo. Donec est mauris
([- ... -]
is deleted text, {+ ... +}
is inserted text).
(There are other diff programs that do a similar thing: e.g. adiff, and maybe some of the ones listed in https://stackoverflow.com/questions/12625/best-diff-tool)
I like Beyond Compare for this kind of side-by-side file comparison. Also lets you do folder comparisons and bit-level comparisons, and you can right-click to select the left-hand file to compare, then another to select the right-hand one; or select two files and right-click Compare to bring them both up straight away.
I use DiffMerge which is free and available on many platforms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With