xdiff - X11/Motif based file comparator and merge tool.
xdiff [-Dwib] [-N stdin name] path1 path2
xdiff is a graphical browser for viewing the differences between two
files and can be used to produce a merged version. The text of the two
files are presented side by side with their differences highlighted for
The two paths supplied on the command line identify the files to be
compared. One of the two paths must be a file. The other may be one of
three things. Another file, a directory, in which case the last
component of the file name will be appended to the directory to form the
other file name, or a '-', in which case the input for that path will be
read from standard input.
OPTIONS FOR XDIFF
-N When input is read from stdin this option specifies the string to
use in place of it's name in the title bar. If not specified the
string "<stdin>" is used.
-D If there are no differences then exit quietly with exit code of 0.
-w Passed on to diff(1). Ignore whitespace when comparing the two
-b Passed on to diff(1). Ignore trailing blanks when comparing the two
-i Passed on to diff(1). Ignore case when comparing the two files.
- Not really an option. Use stdin as one of the files. See above.
The xdiff window is divided into 4 main areas. These are, the menu bar at
the top of the window, a message line just below it, an overview area on
the right side of the window and a text area occupying the remainder. The
text area is further divided into two text windows, one for each file, a
vertical slider between them and a horizontal slider underneath each text
xdiff uses diff(1) to determine the differences between the two files.
The text of the two files is displayed in two scrollable windows in the
main area of the window. Differences are highlighted using different
colours for the foreground and background. These may be specified by the
user as described below in the section on user preferences. A vertical
slider separates the two text areas and controls the vertical positioning
of both text areas simultaneously. The size of the thumb of the slider
is scalled to represent the amount of text visible in the windows.
xdiff can be used to merge the differences from the two files into third.
To select the desired differences the user interacts as follows. To write
this merged version see the section of the File menu.
With the pointer in the left window and pressing the left button the
cursor line moves to the line under the pointer. If this line is in a
difference region then the the left region is selected. Similarly the
differences in the right window may be selected by pressing the left
button on the difference in the right window.
Pressing the middle button with the pointer in either the left or right
windows will move the cursor line to the line under the pointer. If this
is within a difference region then a selection of only the cursor line is
made. This allows a finer level of selection of which text will appear
in the merged output.
Holding the Shift key will cause the region or line, as described above,
to have it's selection removed.
Pressing the right button while in either the left or right windows will
post a popup menu. This popup's methods are to move to other difference
regions. Accelerators may be attached to provide quick navigation using
Go to the first line of the next difference region.
Go to the last line of the previous difference region.
Go the the first line of the next difference region that is still
Go the the last line of the previous difference region that is still
The overview window appears at the right side of the xdiff window. It's
purpose is to show graphically the number, location and size of the
differences between the two files. This display consists of two columns
representing the files and their differences and an area in between where
lines indicate where the differences occur with respect to the other
file. A small arrow is shown in each column and represents the position
of the cursor line in that file. The relative lengths of the files are
shown by comparing the lengths of the two columns.
Pressing any button while the pointer is in the overview area will move
the cursor line to the position in the file indicated by the pointer
position. If the pointer is in the left half of the overview window the
line will be determined from the left file and from the right file if the
pointer is in the right half. The cursor line will then be displayed in
the center of the text windows.
xdiff has a menu bar consisting of six buttons. These are listed below
and described in more detail in the sections that follow.
Contains output commands and exit.
Contains searching and cursor movement functions.
Contains functions that apply to the entire file.
Contains functions that apply to a single difference region.
Contains functions that apply to a single difference line.
Interface to access the online help.
This menu is used to save the merged text to a file and to exit xdiff.
Before a save can be performed all differenced must have a selection. If
not, an error message is displayed in the message line and the cursor
line is moved to the first line which does not have a selection. After a
save to a file, a message will be displayed in the message line to
indicate the status of the save. If the resource confirmWrite is set to
True then a confirmation dialog is presented before a save allowing the
user to confirm the write or cancel the operation. The default for the
confirmWrite resource is True.
If you attempt to save to the left file or the right file when that file
has been read from the standard input xdiff will write the output to
standard output. This allows xdiff to be used in a filter chain like all
well behaved Unix utilities.
Save as Right
Short cut to save the merged text to the file on the right.
Save as Left
Short cut to save the merged text to the file on the left.
Save As ...
Save As will present the user with the Motif file selection box. If
the user presses the OK button then the merged text will be written
to the specified file subject to the confirmation described above.
When writing the regions of common text using Save As the text from
the left file is used. This may yeild surprises if the -w -b -i
flags are used. Although the text is indicated as being the same it
may not be.
Leave xdiff unconditionally.
This menu contains functions for search and cursor movement.
Search will present a dialog box containing an editable text field
and a Search and Cancel button. The user may enter a regular
expression in the text field to specify the search pattern.
Pressing Enter or pressing the Search button will initiate the
search on all text in both files. A small diamond will appear in the
overview area for each line that matches the search pattern. To move
to a match you may click on one of the diamonds in the overview area
or use the Search Next or Search Previous buttons from this menu.
Move the cursor from its current position to the next match from
either file. If there are no more matches then it the cursor is
positioned at the bottom.
Move the cursor from its current position to the previous match from
either file. If there are no more matches then it the cursor is
positioned at the top.
The cursor line is moved down half the number of visible lines and
then that line is centered in the window if possible. The
functionality of this and the following buttons in this menu are
really not required since it can all be done using the scroll bars.
They are included so that accelerators may be added. In this way the
operation of xdiff can be completely controlled from the keyboard.
The cursor line is moved up half the number of visible lines and
then that line is centered in the window if possible.
The cursor line is moved to the next line. That line is the centered
in the window if possible. This gives the effect of the text
scrolling under a stationary cursor.
The cursor line moves as above but in the other direction.
The cursor line is set to the first line. That line is displayed at
the top of the window.
The cursor line is set to the last line. That line is displayed at
the bottom of the window of possible.
The files are diff'd again. Any selection information is lost. The
intention is that you can hand-edit one of the files and then rediff.
This can provide a major improvement in ease of merging
This menu contains operation that affect the entire file.
Selects all the difference regions from the left file.
Selects all the difference regions from the right file.
All regions from both files are unselected. Only common text will be
included in the merged output.
Removes all selections that have been made.
Specifies that tabs should be expanded to 4 spaces.
Specifies that tabs should be expanded to 8 spaces.
Each line of text will be prefixed with the line number from its
file. Regions of absent text will not have a line number.
The functions of the Region Menu use the location of the cursor line to
specify the region for which the function is to be performed. These
functions will only work when the cursor line is on a difference.
The entire difference region from the right file is selected.
The entire difference region from the left file is selected.
Both the left and the right regions are unselected. Neither region
will be included in the merged output.
Any previous selection made to this region will be removed.
In the case when the text has changed between the left and the right
files and it is desired to have both differences appear in the
merged output split right can be used to create two differences so
that each can then be selected individually. Split right will list
the text from the right file first and then the text from the left
file. Any selection that has been previously made to the region will
be applied to both regions after the split.
Same as Split Right except that the text from the left file is
This menu's functions use the location of the cursor line to specify the
line for which the operation is to be performed. These functions will
only work when the cursor line is on a difference.
Only the cursor line is selected from the right file.
Only the cursor line is selected from the left file.
The cursor line for both sides are unselected and so neither line
will be included in the merged output.
Any previous selection made to this line will be removed.
To obtain help for any widget in the main window. Selecting the help
on context button will cause the cursor to change to a question
mark. Move this cursor to any of the widgets and click. A help
window will appear to describe the widget and it interactions.
Provides general information about xdiff.
The differences obtained from diff(1) can be classified into 4 types.
Common Text which is present in both files.
Only text is text that appears only in one file.
When text is missing from a file the void is called Absent. This
always accompanies Only text.
Text which has been changed between the files is called Changed
Unselected text will use the types above. Once a selection has been made
the following types will apply.
When the user has selected one of the two sides of a difference then
that will be selected the other side will become deleted.
This text is not desired in the merged output.
These names are used to form X11 resources names to determine the users
Each of these categories may have different colours for foreground and
background. They may also have a different font. Any unspecified fonts
will default to the font for fontCommon. To specify the foreground
resources name prefix the name with 'fgc' the background is specified by
prefixing the name with 'bgc'. To specify the font, prefix with 'font'.
From the app-defaults file the Common text is specified with.
The cursor colour may be specified using the resource 'cursorColour' This
colour is used to outline the current line in the text windows and the
outline of the triangular indicator in the overview area. Lines that
match the pattern specified in the search window may be outlined in a
different colour to indicate the match. The resource used to specify
this is 'matchColour' if not specified the cursorColour is used.
xdiff uses a temporary file when reading from stdin. This file will be
located in $TMPDIR if it is defined otherwise it will be located in
/usr/tmp. The file name will be of the form xdiffXXXXXX.
Application defaults for xdiff can be found in /usr/lib/X11/appdefaults/Xdiff.
The default accelerator keys used by xdiff have changed from the original
gdiff accelerators to be consistent with those used in other SGI desktop
Rudy Wortel <email@example.com>.
Inspired by gdiff written by Andrew C. Myers.
PPPPaaaaggggeeee 8888 [ Back ]