WebStorm 2016.3 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 | Local Changes tab | - /help/img/idea/2016.3/icon_showDiff.png
Version Control tool window | context menu of a folder or file | Show Diff

In this section:

Basics

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 WebStorm. To do this, execute the following command:

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

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

Diff & Merge viewer

ItemTooltip and ShortcutDescription
/help/img/idea/2016.3/arrowUp.png/help/img/idea/2016.3/arrowDown.pngPrevious Difference / Next Difference Shift+F7 F7
Use these buttons to jump to the next/previous difference.

When the last/first difference is hit, WebStorm 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.

/help/img/idea/2016.3/comparePreviousFile.png
/help/img/idea/2016.3/compareNextFile.png
Compare Previous/Next File
Alt+LeftAlt+Right
Click these buttons to compare the local copy of the previous/next file with its update from the server.
/help/img/idea/2016.3/icon_show_paths.pngGo To Changed File Ctrl+NClick this button to display all changed files in a current change set (and navigate to them).
/help/img/idea/2016.3/edit.png Jump to Source
F4
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
/help/img/idea/2016.3/diffViewer_type.png
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.
Whitespace
/help/img/idea/2016.3/diffViewer_whitespaces.png
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
/help/img/idea/2016.3/diffViewer_highlight.png
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.
/help/img/idea/2016.3/collapseAll.png 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 & Merge settings page.
/help/img/idea/2016.3/sync_scrolling.pngSynchronize scrollingClick this button to simultaneously scroll both differences panes; if this button is released, each of the panes can be scrolled independently.
/help/img/idea/2016.3/cogwheel_blue.pngEditor 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.

/help/img/idea/2016.3/moveToOtherChangelist.png 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.

/help/img/idea/2016.3/external_tool.pngShow 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.

/help/img/idea/2016.3/help.pngHelp
F1
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.
/help/img/idea/2016.3/icon_InsertReplace.png/help/img/idea/2016.3/icon_InsertReplace2.pngUse 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 /help/img/idea/2016.3/icon_InsertReplace.png/help/img/idea/2016.3/icon_InsertReplace2.png to apply changes. This behavior is the default one.
  • Press Ctrl to change /help/img/idea/2016.3/icon_InsertReplace.png /help/img/idea/2016.3/icon_InsertReplace2.png to /help/img/idea/2016.3/arrowRightDown.png or /help/img/idea/2016.3/arrowLeftDown.png and append changes.
Merge actions
/help/img/idea/2016.3/leftDiff.png//help/img/idea/2016.3/rightDiff.png//help/img/idea/2016.3/branchDiff.pngCompare Left and Middle/Middle and Right/Left and Right ContentsClick these buttons to compare left/middle/right parts in a new window.
/help/img/idea/2016.3/applyNotConflicts.pngApply All Non-Conflicting ChangesClick this button to apply all non-conflicting changes. You can also make this behavior automatic, by selecting the check box Automatically apply non-conflicting changes in the Diff & Merge page of the Settings/Preferences dialog.
/help/img/idea/2016.3/applyNotConflictsLeft.png//help/img/idea/2016.3/applyNotConflictsRight.pngApply Non-Conflicting Changes from the Left/Right SideClick these buttons to merge non-conflicting changes from the left/right parts of the dialog.

Keyboard shortcuts

Keyboard shortcutDescription
Ctrl+Shift+DUse this keyboard shortcut to show the popup menu of the most commonly user diff commands.
Ctrl+Tab Use this keyboard shortcut to switch between the left and the 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. Conflicts will be kept in sync with the text.

Context menu commands

This context menu is available in the middle of the editor:

ItemDescription
Show WhitespacesSelect this check command to show whitespaces as the dots in the Differences Viewer .
Show Line NumbersSelect this check command to show line numbers in the Differences Viewer.
Show Indent GuidesSelect this check command to have WebStorm display vertical lines in the Differences Viewer to indicate positions of indents.
Use Soft WrapsSelect this check command to have WebStorm wrap the lines of code, when the dialog box is resized.
Highlighting levelUse this menu item to select the highlighting level in the Differences Viewer. To learn more about the level of highlighting, refer to the description of the Status Bar.
AnnotateSelect this check command to annotate the changes.

This context menu is available in both editors:

ItemDescription
Accept/AppendSelect these commands to accept or append the lines shown in the Differences Viewer.
Compare with ClipboardSelect this command to compare the file in the respective pane of the Differences Viewer with the contents of the the Clipboard.
AnnotateSelect this check command to annotate the changes.

This context menu is available in the right-hand strip of the Differences Viewer:

ItemDescription
Go to high-priority problems only/Go to next problemClick one of these radio-buttons to define the way of navigating between the encountered problems.
Customize highlighting levelClick this command to show the slider to change the highlighting level in the Differences Viewer. To learn more about the changing the highlighting level, refer to the sections Status Bar and Changing Highlighting Level for the Current File .
Show code lens on scrollbar hoverSelect this check command to switch the Differences Viewer to the lens mode.

See Also

Last modified: 1 December 2016