File Comparison with FileMerge

Wherein I explain the anatomy of a FileMerge window

FileMerge is a visual diff utility included with the developer tools that ship with Mac OS X. As its name suggests, it is intended to help compare and resolve differences between files. It is particularly useful for quickly and clearly reviewing changes between different revisions of a single file under version control.

You can choose which files to compare with a dialog

Compare Files dialog

or via the opendiff command:

opendiff original new

For this example, I will compare the contrived sample files used in Wikipedia’s diff article. In either use case, the files are displayed side-by-side with differences highlighted:

FileMerge window

Blue highlights indicate changes. The regions where these changes occurred in each file are connected by gray highlights.

Scrolling is synchronized to show most unchanged areas together; as you scroll, each pane moves at variable speed to maintain this visual correspondence between reference points. It’s nice.

The relative location of each change in the file is indicated by a tick mark in the scroll bar. For long files, these marks act like a simple histogram to summarize the distribution of changes throughout the file.


A dark border surrounds the currently selected difference (number 2, in this example). The up or down arrows move the selection to the previous or next difference.

The left and right arrows keys can be used to select which version of the current region of change should take precedence if you save a merged version of the files. In this example, and by default, the arrows in the center column indicate that the file on the right always takes precedence.

The separator near the bottom of the window can be dragged up to reveal a preview of the merged file. The Actions menu offers additional ways to merge the selected change.


FileMerge can preprocess a file if a command line filter is assigned to the file’s extension. This can be used to compare dynamically-generated text representations of binary files.

Default FileMerge filters


Update: The new application Changes performs a similar function with the advantage of Unicode support. Might be especially useful for revising localized files like message catalogs.

Posted on Tuesday, January 1st, 2008. Tags: .