Compare selected files using the Diff tool
Use the Diff tool to compare two selected files.
There are several methods for selecting the files to compare:
- Select Tip:
If your Diff output is too large, you can reduce it by selecting Try hard to find a smaller set of changes. This might cause Diff to run more slowly.
, and specify the left and right files in the Diff dialog. - Open the first file in the Code Editor and select Tip:
Alternatively, in the Projects or Files view, right-click on the filename and select Compare From to select the first file in the comparison. Then right-click on another filename and select Compare file1 To.
. Open the second file and select . - Open a file in the Code Editor, and select . Select the second file from the file browser.
- On the command line, enter
generostudio -diff file1 file2
.
Specify how the differences are displayed by using these options from the Diff menu:
- Diff View
- Displays differences between the files in a single pane document. This is also called single pane diff mode. Added and modified lines are highlighted. Deleted lines are identified by location but not displayed.
- Diff View with Deleted Blocks
- Displays differences between the files in a single pane document. Added, modified, and deleted lines are highlighted.
- Vertical Dual Diff View
- Displays the left and right files vertically.
- Horizontal Dual Diff View
- Displays the two files horizontally. The "left file" displays on the top and the "right file" displays on the bottom.
Dual diff views are also called two pane diff mode.
Example: Vertical Dual Diff View
This figure shows Vertical Dual Diff View. Side-by-side comparison shows the differences between files.
Viewing differences between files
The Diff tool flags differences between files with color-coded markups in the Code Editor gutter. The default colors are:
- Green - added lines
- Orange - modified lines
- Red - deleted lines
Locate differences between the files by using the navigation options from the Diff menu: First Difference, Previous Difference, Next Difference, and Last Difference.
You can also move through the differences using the diff toolbar arrows (next to Difference 1 of N). If these arrows are not visible, open the Code Editor Preferences and select Show diff options in editor.
To specify display options for the Diff tool, select , then (or, if you are on a Mac, ) .
Copying changes between files
You can copy content from one file to another. The content can be coped from the base file to the user file, or vice versa; for an explanation of base file and user file, see Table 1.
File | Single-pane Diff View | Vertical Dual Diff View | Horizontal Dual Diff View |
---|---|---|---|
Base File | First file selected | Left file | Top file |
User File | Second file selected | Right file | Bottom file |
Switch to Vertical Dual Diff View before copying. The arrows in the context menu will then show the direction for copying the content.
To copy a single change, place the cursor in the line of marked code, right-click and select Copy to Base File or Copy to User File.
For example, in Figure 2, select Copy to Base File to copy the
selected line (CALL displayText()
) from the right file to the left
file. Select Copy to User File to copy the line from the left
file to the right file (deleting the added line).
To replace the content of one file with another, select
or from the menu.