On this page:

Introduction

IntelliJ IDEA enables you to compare arbitrary files in project (including image files), selected file with the editor, or compare a file in the editor with the Clipboard contents. All comparisons are performed in the Differences viewer.

Comparing two files

  1. Press and keep holding ^ for Windows and Linux or for macOS and click the two files to compare in the Project tool window.
  2. On the context menu of the selection, choose Compare Files , or press ⌘D⌘D⌘D^ D^ D. The Differences Viewer for Files opens, with the differences being color-highlighted.

    It is enough to select a single file in the Project tool window. In this case the context menu command is Compare File with Editor, and the Differences Viewer shows the contents of the selected file on the left pane, and the contents of the active editor tab on the right pane.

  3. View the differences and apply them, if necessary, using the chevron buttons ../../Shared/icon_InsertReplace.png../../Shared/icon_InsertReplace2.png.

    Note that keeping ^ (for Windows and Linux) or (for macOS) pressed turns the chevron buttons ../../Shared/icon_InsertReplace.png../../Shared/icon_InsertReplace2.png to ../../Shared/arrowRightDown.png../../Shared/arrowLeftDown.png. Click these buttons to append changes.

    Keeping pressed turns the chevron buttons ../../Shared/icon_InsertReplace.png../../Shared/icon_InsertReplace2.png to ../../Shared/close1.png. Click this button to revert changes.

    ../../Shared/compareFiles.png

Comparing a file in the editor with the Clipboard contents

  1. Open the desired file in the editor.
  2. Right-click the editor pane and choose Compare with Clipboard on the context menu.
  3. View and manage differences in the Differences Viewer for Files.

Comparing a file with the editor contents

  1. Right-click the desired file in the Project tool window.
  2. Choose Compare File with Editor on the context menu.
  3. View and manage differences in the Differences Viewer for Files.