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 Tools > Diff, and specify the left and right files in the Diff dialog.
    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.

  • Open the first file in the Code Editor and select Diff > Compare From. Open the second file and select Diff > Compare file1 To.
    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 a file in the Code Editor, and select Diff > Compare With. 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.

Figure: Vertical Dual Diff View display mode

This figure is a screen shot of the Vertical Dual Diff View.

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.

Tip:

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 Tools > Preferences (or, if you are on a Mac, Genero Studio > Preferences), then Code Editor > Diff Preferences. See Diff tool preferences for further details.

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.

Table 1. Base File and User File
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
Tip:

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).

Figure: Copying changes across files

This figure shows two files being compared in Vertical Dual Diff mode. The context menu is displayed, with Copy to Base File highlighted.

To replace the content of one file with another, select Diff > Copy All to Base File or Diff > Copy All to User File from the menu.