PhpStorm 2016.1 Help

Differences viewer for files

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.

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

<path to PhpStorm executable file> diff <path_1> <path_2>

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

where path_1 and path_2 are paths to the files you want to compare.

Diff viewer

ItemTooltip and ShortcutDescription
arrowUparrowDownPrevious Difference / Next Difference Shift+F7 F7
Use these buttons to jump to the next/previous difference.

When the last/first difference is hit, PhpStorm suggests to click the arrow buttons F7/Shift+F7 once more and compare other files, depending on the Go to the next file after reaching last change option in the Differences Viewer settings.

This behavior is supported 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_pathsGo To Changed File Ctrl+NClick this button to display the path to the compared file.
edit Jump to Source
Click this button to open the selected file in the active pane in the editor. The caret will be placed in the same position as in the Differences Viewer.
Viewer type
Use this drop-down list to choose the desired viewer type. The side-by-side viewer has two panels; the unified viewer has one panel only.

Both types of viewers enable you to

  • Edit, for example, type text. Note that one can change text only in the right-hand part of the default viewer, or, in case of the unified viewer, in the lower ("after") line.
  • Perform the Apply/Append/Revert actions.
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 all differences are highlighted. This option is selected by default.
  • Trim 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 By word mode.
  • 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 whitespaces (as in the 'Ignore whitespaces' option)
    • all added or removed lines consisting of whitespaces only
    • all changes consisting of splitting or joining lines without changes to 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.
The available options are:
  • Highlight words: the modified words are highlighted
  • Highlight lines: the modified lines are highlighted
  • Highlight split changes: if this option is selected, 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.
  • Do not highlight: 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 fragmentsClick this button to collapse all unchanged fragments in both files. The amount of non-collapsible unchanged lines is configurable in the Diff settings page.
sync_scrollingSynchronize scrollingClick this button to simultaneously scroll both differences panes; if this button is released, each of the panes can be scrolled independently.
cogwheel_blueEditor settingsClick 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.

Note that same commands are duplicated in the context menu of the differences viewer gutter. Right-click the gutter to show the menu of check commands.

Include into commit Alt+I This checkbox only appears if you invoke the Differences Viewer from the Commit Changes dialog with multiple changed files (all of which are deselected), and you explore the differences between them and hit the last difference in a file.

Select this checkbox if you want to include the file you've reviewed into the commit.

moveChangelistItems Move to Another Changelist F6 This button only appears if you invoke the Differences Viewer from the Commit Changes dialog with multiple changed files (all of which are deselected), and you explore the differences between them and hit the last difference in a file.

Click this icon to move the file you've reviewed to another changelist.

external_toolShow diff in external toolClick this button to invoke an external differences viewer, specified in the External Diff Tools settings page.

This button only appears on the toolbar when the Use external diff tool option is enabled in the External Diff Tools settings page.

Click this button to show the corresponding help page.
Ctrl+TabUse this keyboard shortcut to switch between the panes of the Differences viewer. The active pane has the cursor.
icon_InsertReplaceicon_InsertReplace2Use these chevron buttons to apply differences between panes (in case of the side-by-side viewer) or between lines (in case of the unified viewer).

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_InsertReplace icon_InsertReplace2 to arrowRightDown or arrowLeftDown and append changes.

Keyboard shortcuts

Keyboard shortcutDescription
Ctrl+Shift+DUse this keyboard shortcut to show the popup menu of the most required diff commands.
Ctrl+Tab Use this keyboard shortcut to switch between the left and right panes.
Ctrl+Shift+Tab Use this keyboard shortcut to select the position obtained by Ctrl+Tab, in the opposite pane.
Ctrl+Z/Ctrl+Shift+Z Use this keyboard shortcut to undo/redo a merge operation. So doing, conflicts are kept in sync with the text.

See Also

Last modified: 12 July 2016