Anchor Pairs¶
Anchor pairs let you manually pin a specific line on the left side to a specific line on the right side. When anchors are set, the diff algorithm is constrained to honour those alignments: the lines you pinned will always be shown as a pair, and the algorithm computes the changes around them.
This is useful when the automatic alignment produces a misleading result - for example, when a large block has been moved and the algorithm aligns the wrong pair of similar lines.
Adding an Anchor¶
- Hold Ctrl and click a line on the left side. A pending anchor marker (◆) appears in the gutter of that line.
- While the left line is pending, hold Ctrl and click the corresponding line on the right side.
- The anchor pair is created. Both lines are marked with ◆ in their gutters and the diff re-runs.
Tip
You can set multiple anchor pairs. The algorithm splits the file at each anchor and computes the diff independently for each segment between anchors.
To cancel a pending left anchor before completing the pair, press Esc.
Removing an Anchor¶
Right-click the ◆ marker in the gutter of either line in the pair. The anchor is removed and the diff re-runs.
Clearing All Anchors¶
Click the × Anchors button that appears in the comparison options bar when any anchors are active. All anchor pairs are cleared and the diff re-runs.
Anchors are also cleared automatically when you load a different file into either side.
When to Use Anchors¶
Anchors are a last resort for cases where none of the three built-in algorithms (Myers, Patience, Histogram) produce a readable alignment. Before reaching for anchors, try switching to the Histogram algorithm in the comparison options bar - it often handles moved or reorganised content better than the default Myers algorithm.
See Algorithms for guidance on choosing an algorithm.