compare command

Use the compare command to compare the current document to a specified file.  Lines that exist in the specified file but not in the current document are highlighted with the styleAttributes.deletedLines style attributes.  Lines that exist in the current document but not in the specified file are highlighted with the styleAttributes.addedLines style attributes.

 

Syntax

compare { clear
        | next
        | previous
        | refresh
        | [ ignoredStyles styleChars ] { prompt [ "fileName" ]
                                       | [ [ fileOptions ] "fileName" ]
                                       }
        } 

 

Parameters

clear Use the clear parameter to remove the compare information from a previous compare session.
next Use the next parameter to move forward to the next mismatch.  This will not wrap around to the top of the document.
previous Use the previous parameter to move backward to the previous mismatch.  This will not wrap around to the bottom of the document.
refresh Use the refresh parameter to refresh the comparison against the previously specified file, using the latest changes in the current view.
ignoredStyles styleChars Use the ignoredStyles parameter to indicate that the text corresponding to the style characters specified by the styleChars parameter should be ignored in the comparison.  White space will also be ignored.  Style characters are set by document parsers.
prompt [ "fileName" ] Use the prompt parameter to indicate that the compare file dialog should be displayed to allow the user to select a file.  If the optional parameter fileName is specified, the compare file dialog will be initialized with the specified file name.
fileOptions Optional settings for the compare file, in this format:
[ sequenceNumbers numColumn numWidth textColumn textWidth ]
[ encoding charEncoding ]
Use the sequenceNumbers parameter to specify that the sequence numbers setting of the file is numColumn numWidth textColumn textWidth.  If not specified, the compare file is assumed to have the same sequence numbers setting as the current document.  Refer to the sequenceNumbers editor parameter for additional information on specifying sequence numbers.

Use the encoding parameter to specify that the character encoding of the file is charEncoding.  If you specify an empty string (""), the editor tries to detect the file encoding by itself, and defaults to the native encoding if unsuccessful.  If not specified, the compare file is assumed to be in the native (platform default) character encoding.
"fileName" Use the fileName parameter to indicate the file that should be used.  If no filename is specified, the document is compared with the saved version of its underlying file.

 

Status

The status parameter will be set to one of the following:

null Indicates that the compare command successfully located the specified file.
file.notFound Indicates that the compare command could not locate the specified file.
file.errorReading Indicates that the compare command encountered an error while reading the file.

 

Description

Lines which exist in the current document but not in the compare document are highlighted and continue to be part of the document.  Lines that do not exist in the current document but exist in the compare document are inserted as show elements in the current view.  They are protected and cannot be edited.  Since they are show elements, they will not be saved with the document.

The comparison takes into account the settings of the compare. parameters.  After changing any of these settings, another compare or compare refresh command must be issued for the view to reflect the changes.

 

Examples

compare prompt
compare "test.java"
compare encoding Cp850 "test.java"
compare ignoredStyles "c" prompt "test.java"
compare clear
compare next
compare previous
compare refresh 

Related concepts
Editor commands, actions, and parameters

Related reference
compare.columns parameter
compare.endColumn parameter
compare.ignoreCase parameter
compare.ignoreComments parameter
compare.ignoreLeadingBlanks parameter
compare.ignoreSequenceNumbers parameter
compare.ignoreTrailingBlanks parameter
compare.ignoreAllBlanks parameter
compare.startColumn parameter
sequenceNumbers parameter
show parameter
status parameter
style parameter
styleAttributes parameter

compare action
compareClear action
compareNext action
comparePrevious action
compareRefresh action
Default editor commands