IntelliJ IDEA 14.1.1 Help

Differences Viewer

Project tool window | context menu of a file | Compare File with Editor
Project tool window | context menu of a file | Compare Files
Version Control tool window | Repository and Incoming tabs | icon_showDiff
Version Control tool window | context menu of a folder or file | Show Diff

In this section:


This dialog is displayed every time you compare two files, or compare two versions of a file (local changes or changes between local files and their revisions in a remote repository). You can compare files of any types, including binaries and .jar files.

The differences viewer provides a powerful editor that enables code completion, live templates, etc.

Note that you can open the differences viewer without running IntelliJ IDEA. To do this, execute the following command:

<path to IntelliJ IDEA executable file> diff <path_1> <path_2>
where path_1 and path_2 are paths to the files you want to compare.

Diff viewer

Item Tooltip and Shortcut Description
arrowDown arrowUp F7
Use these buttons to jump to the next/previous difference.

When the last/first difference is hit, IntelliJ IDEA suggests to click the arrow buttons F7/Shift+F7 once more and compare other files, depending on the check box in the Diff page.

This behavior is available only when the Differences Viewer is invoked from the Version Control tool window.

Compare Previous/Next File
Click these buttons to compare the local copy of the previous/next file with its update from the server.
icon_show_paths Go To Changed File Ctrl+N Click this button to display the path to the compared file.
edit Jump to Source
Click this button to open the file in the active pane in the editor. The caret will be placed in the same position as in the Differences Viewer.
Type of viewer
Use this drop-down list to choose the desired viewer type. The default viewer has two panels; One-side viewer has one panel only.
Use this drop-down list to define how the differences viewer should treat white spaces in the text.
  • Do not ignore: white spaces are important, and the all the differences are highlighted. This option is selected by default.
  • Trim whitespaces: Ignore the whitespaces ("\t", " ") , if they appear in the end and in the beginning of a line.
    • If two lines differ in trailing whitespaces only, these lines are considered equal.
    • If two lines are different, such trailing whitespaces are not highlighted in the mode By word.
  • Ignore whitespaces: white spaces are not important, regardless of their location in the source code.
  • Ignore whitespaces and empty lines: the following entities are ignored:
    • all the whitespaces (as in the option 'Ignore whitespaces')
    • all the added or removed lines consisting of the whitespaces only
    • all the changes consisting of splitting or joining lines without changes to the non-whitespace parts.
      For example, changing a b c to a \n b c is not highlighted in this mode.
Highlighting mode
Select the way differences granularity is highlighted.
Possible options are:
  • By word: changed words are highlighted
  • By line: changed lines are highlighted
  • By word in chunks: if this option is selected, the big changes are split into smaller 'atomic' changes.
    For example, A \n B vs. A X \n B X will be treated as two changes instead of one.
  • No highlighting: if this option is selected, the differences are not highlighted at all. This option is intended for significantly modified files, where highlighting only introduces additional difficulties.
collapseAll Collapse unchanged fragments Click this button to collapse all unchanged fragments of both files. The amount of non-collapsible unchanged lines is configurable in the page Diff.
sync_scrolling Synchronize scrolling Click this button to simultaneously scroll both differences panes; if this button is released, each of the panes can be scrolled independently.
cogwheel_blue Editor settings Click this button to reveal the drop-down list of available check commands. Select or clear these check commands to show or hide line numbers, indentation guides, white spaces, and soft wraps.
external_tool Show diff in external tool Click this button to invoke an external differences viewer, specified in the External Diff Tools page.

This button only appears on the toolbar, when the check box Use external diff tool is selected in the External Diff Tools page.

help Help
Click this button to show reference page.
Ctrl+Tab Use this keyboard shortcut to switch between the panes of the Differences viewer. The active pane has the cursor.
icon_InsertReplace icon_InsertReplace2 Use these chevron buttons to apply differences between panes.

The chevron buttons can change their behavior:

  • Click icon_InsertReplaceicon_InsertReplace2 to apply changes. This behavior is the default one.
  • Press Ctrl to change icon_InsertReplaceicon_InsertReplace2 to arrowRightDown or arrowLeftDown and append changes.
  • Press Shift to change icon_InsertReplaceicon_InsertReplace2 to close1 and revert changes.
    Note that pressing Shift does not work when only one file is editable.
Ctrl+Shift+D Use this keyboard shortcut to show the popup menu of the most required diff commands.

See Also

Last modified: 6 April 2015