Merge text comparisons make it possible for you to compare and merge text files, or text that you type into Merge. You can copy and paste text into Merge from other applications, or directly open and compare the text from Microsoft Office, OpenDocument, PDF and RTF files. Merge can also apply special formatting to XML and XHTML files (see below), helping you to see changes more clearly.
If you haven’t already, spending a few moments browsing the Instant Overview of File Comparison and Merging will help you quickly become familiar with Merge file comparisons. It may also be helpful to review the Making the Most of the Ribbon (Merge 2020 and later) topic.
Performing a comparison
By default, an empty new text comparison tab is automatically opened when you start Merge. To open an additional, new text comparison:
- Choose the New text comparison item in the drop-down menu of the leftmost ribbon item.
- Or, if you are already viewing a text comparison, click the New text comparison button in the ribbon.
- Or, press Ctrl+L.
The screenshot below shows a new, empty text comparison tab.
Two empty areas where the compared files will be displayed take up the majority of the window. You can type directly into each file pane, or paste text copied from other applications. Alternatively, above each file pane is an entry field that you can use to enter the path to a file that you want to compare.
Specifying the files to compare
To compare two text files, you can type the paths of two files into the entry fields or use the buttons on the right-hand end of the entry fields to choose files to compare.
The Browse button opens a file-browsing window and the Show history button displays a list of the files that you have recently compared. Double-click a row in the list to load and compare the relevant files. Alternatively, hold Ctrl and double-click a file in the list to load only a single file.
Click the Start or recompare ribbon button or press the Enter key when you have chosen two files to compare.
You can also drag and drop files from Windows Explorer on to the filename entry fields or on to the file panes.
Files stored in a version control or SCM system
As well as files on the local disk and network volumes, Merge is also able to directly access and compare files stored within Perforce, Subversion, and local Mercurial and Git repositories. See Virtual File System (VFS) Plugins for more details.
Files stored in an archive
Merge has built-in support for a variety of archive formats (
.tar, etc.) – see the Scan contents of archives (.zip, .jar, .tar, etc.) option documentation for a complete list. Enhanced support for
.7z archives can also be provided by installing the free third-party 7-Zip application and enabling the corresponding Merge option.
Most commonly, you would perform a folder comparison on two (or three) archives and then launch file comparisons from there. However, you can also enter an archive file path directly into the file entry field at the top of the file comparison tab. For example, if you had an archive
\\NAS\home\Hg.tar, you could directly access a file
SomeFolder\example.cpp stored within that archive by entering the path
Accessing other revisions of a file with the Versions button
If there are other versions of the file named in the entry field available for comparison, the Versions button displays a list of these other versions. You can open the same file in both the left and right comparison panes, then use this button to compare a file with an earlier revision of itself.
When the Options…▸Application▸Show file versions from SCM systems option is checked, Merge endeavours to find any other versions of the file you are comparing from the relevant configuration management system repository. If a Perforce, Subversion, Mercurial or Git URI has been specified in the filename entry field, Merge will search the repository from which it loaded the file for any other revisions. Otherwise, if a file has been loaded from the local disk or a network volume and is part of a client workspace, Merge will search the relevant repository for which credentials have been supplied on the Credentials options page.
If the Options…▸Application▸Show file and folder versions from System Restore option is checked, Merge will show any versions of the file you are comparing that have been stored by Windows System Protection or the Araxis Snapshot Service. For more information, see Accessing Versions Stored by Windows System Protection or the Araxis Snapshot Service.
Three-way file comparisons
In addition to two-way file comparison, the Professional Edition of Merge enables you to compare (and, for text files, merge) three files. Please see the Three-Way File Comparison and Merging topic for more information. The Professional Edition also supports the automatic merging of text files.
Comparing the text content of Microsoft Office, OpenOffice.org, PDF, RTF and HTML files
Merge comes with a number of filters that can automatically extract the text content from certain common types of files when they are loaded. This means, for example, that you can drag and drop a pair of Microsoft Word documents on to a Merge text comparison window and have the text comparison automatically extract and compare the text from those documents.
Merge includes text extraction filters for files from the following applications:
- Microsoft Word 97 and later (
- Microsoft Excel 97 and later (
- Microsoft PowerPoint 97 and later (
- OpenDocument text, spreadsheet and presentation files (that is, Writer, Calc and Impress documents) from LibreOffice, OpenOffice.org and NeoOffice (
- Unencrypted Adobe PDF files (
- Rich Text Files (
- HTML files (
Note that Merge is only able to extract literal text stored in spreadsheet files. It is not able to perform calculations on spreadsheet cells.
These filters are all optional and not all of them are enabled by default. Thus, you can compare HTML and RTF files as they are, without conversion. The File Types options page can be used to configure which filters Merge uses and what sort of comparison is started for different file types.
When comparing text documents, it is usually helpful to have Merge wrap long lines of text, breaking them at word boundaries. You can choose this behaviour from the Display options page.
Note that Merge can extract text, but not formatting, from the above file formats. Merge is not therefore able to show you formatting differences. The text filters for these file formats are also one-way – text can be extracted from these types of files, but not written to them. Please also be aware that the filters have various other limitations. They do not, for example, extract bullet and paragraph numbering information from Microsoft Word files, and password-protected documents are unsupported. For some documents, it may therefore be preferable to open them in their native application and copy and paste text from them into a text comparison pane. This will have the benefit of preserving details such as bullet and paragraph numbering.
Finally, be aware that you can use these filters to compare documents of different types. For example, perhaps a client has sent you a PDF of a final version of a contract, created from a Microsoft Word document that you had previously reviewed. You can use Merge to compare the text content of the PDF and Word documents to be sure that they are the same.
Comparing XML and XHTML files
The XML/XHTML ribbon menu contains commands to reformat true XML and XHTML text (but not non-XHTML HTML). Reformatting enables XML/XHTML to be compared more easily, affecting the appearance and layout of the files on-screen and how they are compared. However, it does not change the content of the files: whitespace is not added or removed, neither is content re-ordered. This means that you can see changes clearly in even the most densely formatted XML files, without sacrificing the fidelity of a true textual comparison. Reformatted files can be edited, merged, and saved as usual.
You can use the File Types options page to enable or disable the automatic reformatting of XML and XHTML files when they are opened in a new text comparison.
Only use the XML/XHTML ribbon menu commands (or the aforementioned automatic reformatting) on true XML/XHTML files. An error message will be displayed if these commands are used on non-XML text (e.g. HTML that is non-valid XHTML), and the results may be undefined.
When comparing re-formatted XML and XHTML files, it can be helpful to check the Options ▸ Show line endings ribbon menu item. This will help you identify line breaks that are present in the original text files.
Comparing files with numeric data
Merge is able to compare corresponding numeric values within text files and, if desired, treat them as identical if they are within certain tolerances of one another. One potential use for this is when comparing the output of numerical control (NC) code files from CNC machine tools. Thus, for example, if a numeric comparison absolute tolerance of 0.002 has been defined, then 34.013 and 34.015 would be considered identical, whereas 34.012 and 34.015 would be treated as different. Ratio tolerances are also supported.
Merge only makes allowance for numeric tolerance when comparing files whose type is defined as Text with numeric data on the File Types options page. By default, new installations of Merge will treat files with the
.ptp extension in this way. (Please note, however, that a
.ptp file type is not automatically added when upgrading existing installations of Merge.)
The allowed absolute and/or ratio numeric comparison tolerances for such files are specified on the Text Comparisons options page.
Comparing Intel Hex files
Merge provides special handling for Intel Hex files. For this to take effect, the type of the file must be defined as Text Intel Hex on the File Types options page. By default, new installations of Merge will treat files with the
.hex extension in this way. (Please note, however, that a
.hex file type is not automatically added when upgrading existing installations of Merge.)
For Intel Hex files, record lines (which start with a colon followed by eight hexadecimal characters of control data) are paired for comparison based on the control data only, ignoring any content data. Changed blocks consisting of multiple record lines are broken into individual lines, to show exactly how the lines are paired. The content data that follows the control data is then compared for each pair of lines, and changes are highlighted inline.
The file comparison display
Two sample text files (
test2.txt) are provided in the Merge installation directory. The following screenshot shows the results of a file comparison between these two files.
Changes between the two files are highlighted with colours and linking lines. Linking lines in the centre panel of the file comparison window connect related changes to show exactly how the files are related. You can modify the colours and fonts used in the file comparison window by using the controls in the Fonts and Colours options page.
A summary of the number of removals, insertions and changes that were found between the compared files is shown in the status bar at the bottom of the main Merge application window. The current line and column number for the editing caret is also displayed.
Merge for Windows is optionally able to add vertical padding so that all related blocks of changed and unchanged text in the left and right files remain vertically aligned. This can sometimes be helpful, especially in conjunction with the Intelligently split blocks of changed text based on matched line pairs option, although the drawback is that less text is typically visible on the screen when padding is used.
Vertical padding can be toggled with the ribbon Options ▸Add vertical padding to align changes menu item.
This option ensures only that related blocks of changed and unchanged text remain aligned. If you wish to align consecutive individual lines within those blocks, you will also need to ensure that neither of the ribbon Options ▸Line-wrapping items is checked. With line-wrapping enabled, individual lines within blocks of changed and unchanged text will not generally remain aligned.
The screenshot below shows the same file comparison as previously, except with the addition of vertical padding to align changes.
You can use the Two-way (horizontal) or Two-way (vertical) buttons in the ribbon (or the F11 and F12 keys) to change the layout of the files within the file comparison window so that the compared files are displayed one above the other or side-by-side (the default).
There are many options that you can set to customize how Merge compares and displays files. There are help topics that will enable you learn how to customize Merge so that it produces the best results for you.
As you scroll one file up and down using its scroll bar, the other file is scrolled so that the two files remain aligned in the centre of the display. The centre-point marker (a line of small indentations in the centre of the linking lines panel) indicates the point at which Merge tries to keep related parts of the files aligned. You can temporarily prevent Merge from keeping both files aligned by holding down the Ctrl key whilst scrolling. When you release Ctrl, the files will snap back into alignment.
The small Previous change and Next change buttons below the scroll bars can be used to jump to the previous or next change.
There are thin overview strips within the vertical scroll bars of the left and right panes. These contain markings to indicate the position of changes within the compared files. You can quickly navigate to a change by clicking on the marks in the strip. (If you hold Shift while clicking above or below the scroll-bar thumb, the comparison display will instead scroll up or down by a page.)
You can use the cursor keys to navigate within a file after clicking within it to give it keyboard focus. The following navigation shortcut keys are also available:
- Ctrl+Page Up (or F7) moves the editing cursor to the previous change.
- Ctrl+Page Down (or F8) moves the editing cursor to the next change.
- Ctrl+← and Ctrl+→ moves the editing cursor left and right in word steps.
- Ctrl+Home and Ctrl+End moves the editing cursor to the beginning or end of the file.
- Ctrl+G displays a window that you can use to navigate to a specific line number.
For a full list of keyboard shortcuts, see File Comparison Keyboard Shortcuts.
Merge supports mice with wheels. If you have a three-button mouse, you can click within a file panel with the middle mouse button to enter a panning mode. The file will scroll in the direction you move the mouse. To stop panning, click the middle mouse button again. If your mouse has a wheel, you can use it to scroll up and down within the active file. If your mouse or keyboard has backwards and forwards buttons, you can use them to navigate to the previous or next change.
Unicode/MBCS character encodings and code pages
Merge can compare files encoded with Unicode or MBCS character encodings as well as ASCII files. For MBCS files, Merge can compare files even if they were saved using a codepage different to your default codepage. Please see Working with Character Encodings for more information.
Searching for text
You can search for text in the active file by pressing Ctrl+F or by clicking the Find button in the ribbon.
Switching between multiple file comparisons
Merge allows you to work with multiple file comparisons open at the same time. A tab strip along the top of the application window allows you to switch between file comparisons with a single mouse click.
Bookmarks and comments
As you are comparing or editing files, you may want to set bookmarks to enable you to return to locations of interest later on. Press Ctrl+F2, or click Toggle bookmark in the ribbon, to toggle a bookmark on or off on the current line. To navigate between bookmarks, press F2 or Shift+F2, or use the Next bookmark and Previous bookmark buttons in the ribbon.
Comments can be added to bookmarks, making it easy to note important information or to record a question. To edit a bookmark’s comment, right-click the bookmark and choose the Edit Comment menu item. Bookmark comments are shown as tooltips when you hover the mouse pointer over a bookmark.
Bookmarks and comments are included when you create an HTML comparison report or save a comparison for archival or team collaboration. They are therefore a useful tool for asking questions or making notes in a comparison that will later be emailed to other team members for review.
In addition to the comparison features described above, Merge enables you to edit and merge the files being compared. Please see the Editing Files topic for more information.
Merge provides syntax colouring support for a variety of programming languages:
|C/C++/Obj-C||.c, .cc, .cpp, .cxx, .h, .hh, .hpp, .hxx, .sma, .m, .mm|
|Windows resources||.rc, .rc2, .dlg|
|Flash||.as, .asc, .jsfl|
|VB||.vb, .bas, .frm, .cls, .ctl, .pag, .dsr, .dob|
|Pascal/Delphi||.dpr, .dpk, .pas, .dfm, .inc, .pp|
|HTML/XML/PHP/VXML||.html, .htm, .asp, .shtml, .htd, .php3, .phtml, .php, .htt, .cfm, .tpl, .dtd, .hta, .vxml, .xml, .xsl, .xslt, .svg, .xul, .xsd, .dtd, .axl, .xrc, .rdf, .vcproj, .wxs, .wxi, .docbook|
|Caml/OCaml/F#/SML||.caml, .ml, .mli, .fs, .fsi|
|Fortran||.f90, .f95, .f2k, .f, .for|
|Lisp||.lsp, .lisp, .scm, .smd, .ss|
|Perl||.pl, .pm, .cgi, .pod|
|Python||.py, .pyw, SConstruct, SConscript|
|Scala||.sbt, .sc, .scala|
|Visual DataFlex (using the Smalltalk parser)||.src, .pkg|
|SQL||.sql, .spec, .body, .sps, .spb, .sf, .sp|
Syntax highlighting can be enabled (and colours configured) using the controls in the Syntax Highlighting options page. File extensions and keywords for each language can be changed by editing the
highlight.styles file in the Merge installation directory.
The Unified diff ribbon button provides a quick way to create and view a plain-text description of the changes between the files of a two-way text comparison. It generates a unified-format diff with three lines of context surrounding changes, and UNIX (LF) line endings. The diff is displayed in its own tab. If desired, it can be saved using the Save button in the ribbon, or copied and pasted elsewhere.
Unified diffs can be used as patch files when Comparing Text Files for Patching.
See Creating a File Comparison Report for another way to create unified-format diff files and other types of report.