Compare Editor

The Compare Editor displays two versions of a file in a separate window and highlights their differences. You can search either text pane and edit a working-tree file while comparing it with another version.

Opening a comparison

Select a file in the Files View and choose Query | Show Changes. To compare historical versions, first select the commit or commits in the Graph. The Diff Tools preferences determine whether SmartGit opens the Compare Editor or an external tool.

Use Go To | Previous Change or Go To | Next Change to move between changes. The toolbar provides the same commands. You can also scroll the mouse wheel over the connector between the panes to move between changes.

The vertical overview stripe beside each text pane marks changes throughout the file. Click a colored marker to scroll to that change. The filled bar on the right of the stripe indicates the portion of the file currently visible in the pane.

Find and replace

Click a text pane and choose Edit | Find… to search that pane. Enter Text to Find, then use < Find or Find > to search backward or forward. The search options are:

  • Case-sensitive distinguishes uppercase and lowercase text.
  • Regular Expression search interprets the search text as a regular expression.

A single-line text selection fills Text to Find when you open the dialog. After closing the dialog, use Edit | Find Next or Edit | Find Previous to repeat the search.

In an editable pane, choose Edit | Find and Replace… to enable Replace With. If a single-line selection supplied the search text, the replacement field receives focus so you can enter the replacement immediately. Replace replaces the matching selection and moves to the next match.

Replace All replaces matches throughout the active pane. If the selection spans multiple lines, it replaces only matches within that selection.

Example

To change names such as get_name to read_name, enable Regular Expression search and enter:

  • Text to Find: \bget_([A-Za-z]+)\b
  • Replace With: read_$1 $1 preserves the text matched by the first capture group, ([A-Za-z]+).

Note

Regular-expression searches match within individual lines. In Replace With, use \$ for a literal dollar sign and \\ for a literal backslash.

Editing and saving

Historical file versions are read-only. When a working-tree pane is editable, you can change its text directly. Use Edit | Take Left Block or Edit | Take Right Block to copy a change from the indicated side to the other editable pane. Choose File | Save to write the edited file.