Diffing text files
In its diff mode, P4Merge enables you to compare two text files to locate differences. (P4Merge can also diff image files.)
The purple icon () is associated with the first file you selected, and purple bands highlight text that is in the first file but not the second file. The green icon () is associated with the second file you selected, and green bands highlight text that is in the second file but not the first file.
By default, P4Merge displays diffs in a side-by-side layout. However, you may prefer to view changes closer to each other. In this case, you can switch to single-pane layout. To display diffs in a single pane, go to View > Single Pane Diff Layout. In single-pane mode, deleted text is shown using strike-through text.
To toggle the display of line numbers, click .
For information on diffing files from within P4V, see Diffing files in the Helix Core Visual Client (P4V) Guide.
To diff files:
- Go to File > New Merge or Diff.
-
In the Choose Files dialog box, on the Diff tab, specify the two files to be compared.
-
Click OK.
P4Merge shows each file in its own pane, with differences highlighted in blue and green, respectively.
Syntax highlighting is available (starting with version 2020.2). Click the Show Syntax Highlighting button to toggle the feature on or off.
More than 300 languages supported languages are listed at https://kate-editor.org/syntax/.
If you are working with large text files, see the Support Knowledgebase article, Improving diff results when comparing files with more than 50,000 lines.
Navigate diffs
To move forward and back through individual differences, or to locate specific text or lines, click the toolbar buttons listed below.
Go to next diff |
|
Go to previous diff |
|
Find text |
|
Go to line number |
|
Edit text
If needed, you can edit files directly in P4Merge, provided you are viewing them side by side. In Double Pane Diff Layout, for files that are available in the workspace and writable, the edit file buttons become available in the toolbar:
- Select to edit the file in the left pane.
- Select to edit the file in the right pane.
The edit pane opens at the bottom of the window. Make your changes and save the file.