display | more...

Ediff is an (X)Emacs tool for handling diffs and file merges. The info pages describe it thus:

Ediff provides a convenient way for simultaneous browsing through the differences between a pair (or a triple) of files or buffers (which are called `variants' for our purposes). The files being compared, file-A, file-B, and file-C (if applicable) are shown in separate windows (side by side, one above the another, or in separate frames), and the differences are highlighted as you step through them. You can also copy difference regions from one buffer to another (and recover old differences if you change your mind).

Another powerful feature is the ability to merge a pair of files into a third buffer. Merging with an ancestor file is also supported. Furthermore, Ediff is equipped with directory-level capabilities that allow the user to conveniently launch browsing or merging sessions on groups of files in two (or three) different directories.

Ediff is a seamless user interface to the familiar text-based diff, merge and patch tools of UN*X.

The basic usage -- M-x ediff RET -- asks for the names of the two files you wish to compare (ediff-buffers lets you compare just buffers, if you've already find-file visited these files). After grinding away for a few seconds, you're presented with the two files in windows, along with a small third control window. Keystroke commands in the control window let you scroll between changes. Changes are represented by highlighting -- the entire block in each file is coloured, with additional highlighting for changed text; the current difference is coloured, other differences are greyed. Although the underlying diff tool is line-based, each difference is further refined to the word level (and coloured accordingly). An option lets you ignore whitespace differences (usually you don't care so much about those...).

AND you're still in (X)Emacs, which applies syntax highlighting to your files. Syntax highlighting normally affects the foreground and glyphs, while ediff's highlighting is of the background -- you can see both at once! This is in marked contrast to almost any merge tool I've seen, which considers its inputs plain text. Of course, if you like, you can directly edit the two files too. You scroll through the changes by hitting `p' or `n' in the control window.

Even in this basic form you can use ediff to perform merges. By hitting `a' or `b', you can overwrite one buffer's version of the different region with the other buffer's version. You can also refine your edits manually, with the world's best text editor! More advanced uses include selectively applying and generating patch files or comparing 3 files at once -- either as 3 independent files, or as an ancestor and 2 descendents.

Most vc (version control) packages of (X)Emacs can interface with ediff. The integration is reasonably tight, yet very convenient to the user: ediff doesn't force you to do anything in any particular way.

For large merges, ediff is an excellent choice. It's also very good for small ones, or even for tiny ones. One neat trick is to use C-x n n (narrow-to-region) on two different buffers, then use ediff to compare just those regions.

For the Emacser, nothing comes close.

Log in or register to write something here or to contact authors.