Words on Macs: 5 Spot the difference

Whether or not you use a version control system or versioning, there are times when you need to compare two versions of the same document, and perhaps merge selected changes that have been made from one version to the other.

The tools that I am considering in this article thus take two (or more) documents, work out the differences between them, reveal those differences in a manner which allows their rapid review, and allow you to apply selected changes found in one document to the other. I will also provide brief mention of single and multi-file search and replace using BBEdit, which is one of its biggest selling points.

Cornerstone

Cornerstone comparing files; if you want something grander, you can use an external tool such as Kaleidoscope.
Cornerstone comparing files; if you want something grander, you can use an external tool such as Kaleidoscope.

Compare features in this version control app use FileMerge, but work only for comparisons between versions of files stored in a version-controlled repository, as far as I can tell. They are of standard professional quality, working on files in text formats, but not ‘intelligent’ enough to spot block moves of text.

Xcode

Xcode (with or without Xcode Server) can compare versions stored in a repository, and any two files in text format. The latter feature is used via the Open Developer Tool menu command, selecting File Merge, and uses that app bundled inside the XcodeTools folder. You can of course run FileMerge direct from that folder if you are not already running Xcode.

FileMerge, free with Xcode, has a solid interface to a professional compare and merge engine.
FileMerge, free with Xcode, has a solid interface to a professional compare and merge engine.

FileMerge has attractive graphical devices which enhance its standard professional performance, but it does not spot block moves. Although it is intended for text formats, including a wide range of markup types, as an added bonus it also compares the text content of RTF files, but not word processor XML-based formats such as .docx.

It is a shame that you have to download the whole of Xcode in order to obtain this one component (Apple does not list an unbundled version on the App Store), but it is worth the effort, and certainly a powerful tool for free.

Kaleidoscope

For quite an expensive compare and merge utility (£52.99 from the App Store), I had high expectations of Black Pixel’s flagship app.

It is the most flexible tool in terms of loading documents for comparison, which can be as simple as drag-and-drop, or you can systematically assemble a whole group of files for comparison, a pair at a time, in the same window. The actual compare function works the same as FileMerge, and is sadly not smart enough to spot where words or larger blocks of text have been moved around.

However Kaleidoscope’s flexibility and interface are on a completely different level. Deletions found are shown using red if they are present in the left (port) document, green if present in the right (starboard). Other differences, such as mismatched contents and markup, are highlighted in purple. A pale purple draws your attention to the paragraph containing the text mismatch, and a deeper purple shows exactly what is different.

Kaleidoscope is in a different league, with superb use of colour in its powerful front end. Here is compares a pair of the three files available.
Kaleidoscope is in a different league, with superb use of colour in its powerful front end. Here is compares a pair of the three files available.

Not only that, but you can choose between three different options for displaying the results: Blocks, in which differences are shown in blocks spaced equally across the source files; Fluid, in which lines join areas which differ and both files are shown over their natural length; and Unified, which shows an ingenious single composite view. I can see how different compare tasks would fit best with different display formats.

Although Kaleidoscope handles markup well, tags are not coloured or styled in its views. In some circumstances that might be helpful, but the views could readily dissolve into a riot of colour, leaving you puzzled as to what it all means. On balance I think that the interface is just about perfect, although if you don’t like their use of colour, you can turn that off. There are further bells and whistles, such the option to ignore whitespace, which is valuable.

Another huge benefit is the fact that Kaleidoscope will open and compare the text content of many more file types, including XML-based .docx and .odt, and RTF. However this does not recognise any styling or content markup, which would have to be compared and merged manually using an appropriate editor.

Not content with dealing with such a broad range of text documents, Kaleidoscope can help you with eyeball comparison of most image file formats, and comparing folder contents. I will not cover these in any further detail here, but both are useful adjuncts for many.

Kaleidoscope also integrates with most version control systems, including Subversion, Git, Mercurial, Perforce, and Bazaar, but these are through its command line tool. It integrates fully with the Versions Subversion client, TextMate’s Subversion and Mercurial bundles, the Tower Git client, and SourceTree’s Git and Mercurial clients, but not, apparently, with Cornerstone.

If you want to integrate it with Xcode’s Git server, you will need to purchase Kaleidoscope direct from Black Pixel rather than the App Store, as the latter version requires git and svn to be installed at /usr/bin. It is a shame that these are rather messy, but that is the nature of version control servers, I fear, and should not bother anyone using Kaleidoscope on uncontrolled documents.

BBEdit

Compare text files in BBEdit is effective but basic, and the interface a bit kludgy.
Compare text files in BBEdit is effective but basic, and the interface a bit kludgy.

BBEdit’s compare feature is more basic, and does not stand comparison with FileMerge or Kaleidoscope. It will compare any files if you want, but is only really meaningful for text formats. Differences found are simply highlighted by paragraph, which for unwrapped text is not so helpful, sending you chasing down the long unbroken lines in quest of its findings. It is also not sufficiently specific to help, especially when dealing with small differences. As with the other compare commands, BBEdit’s does not spot any moves, just differences.

BBEdit's search is another matter, and is amazingly powerful in its single- and multi-file forms.
BBEdit’s search is another matter, and is amazingly powerful in its single- and multi-file forms.

Its single- and multi-file search are a different matter: here BBEdit stands in a class of its own. It boasts regular expression (regex) and (Unix) grep support, takes you straight to the hits, and has a bundle of other power options.

This is BBEdit returns its searches - a joy to work with.
This is BBEdit returns its searches – a joy to work with.

Summary

If you are looking for a good free file comparison and merge tool, FileMerge bundled in Xcode should be just the job, although you will need to download the whole of Xcode to get it.

If you have more serious, intense, or sustained work, or want to integrate with a version control system, then Kaleidoscope is more likely to please, and you should at least try it out as a demo.

Although there is nothing wrong with the approach taken in these tools, it is perhaps a little disappointing that no one has yet implemented a smarter compare which could spot text which has moved, instead of identifying it as having been removed from one point and inserted into another. So the differences between FileMerge and Kaleidoscope are not in the engine so much, but the styling, controls, and dashboard.

But when it comes to searching text files, with or without replacement, BBEdit is still the business.