# Diff Viewer for files

> **TL;DR**
> `Project     tool window | context menu of a file | Compare File with Editor`
>
>
>
> `Project     tool window | context menu of a file | Compare Files`
>
>
>
> `Commit tool window` ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.vcs.diff.svg) `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS))
>
>
>
> `Git tool window | context menu of a folder or file | Show Diff`

This Diff Viewer is displayed when you compare two files or 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. To open it, select two files to compare or a file to compare its versions and press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS)). The Diff Viewer will be opened in a new tab.

The Diff Viewer provides a powerful editor that enables code completion, live templates, and other features.

The changes that you apply in the Diff Viewer are automatically applied to the files. You can view the changes in the files at any time while working with the Diff Viewer and after closing it.

![Comparing files in IntelliJ IDEA diff viewer](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_compareFiles.png)

| Color | Description |
| --- | --- |
|  ![New lines](https://resources.jetbrains.com.cn/help/img/idea/2026.2/diff_new_lines_color.png)  Green  | Added |
|  ![Modified lines](https://resources.jetbrains.com.cn/help/img/idea/2026.2/diff_changed_lines_color.png)  Blue  | Modified |
|  ![Deleted lines](https://resources.jetbrains.com.cn/help/img/idea/2026.2/diff_deleted_lines_color.png)  Gray  | Deleted |

## Diff & Merge viewer

| Item | Tooltip and Shortcut | Description |
| --- | --- | --- |
| ![the Previous Difference button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.up.svg)/![the Next Difference button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.down.svg) | Previous Difference / Next Difference `Shift+F7` (Windows), `⇧ F7` (macOS), `⇧ F7` (IntelliJ IDEA Classic (macOS)), `⌘ [` (macOS System Shortcuts), `Shift+F7` (XWin), `Shift+F7` (GNOME), `Shift+F7` (KDE), `Shift+F7` (Emacs), `Shift+F7` (Sublime Text), `⇧ F7` (Sublime Text (macOS)), `Shift+F7` (NetBeans), `Shift+F7` (Visual Studio), `⇧ F7` (Visual Studio (macOS)), `Shift+F7` (Eclipse), `⇧ F7` (Eclipse (macOS)) `F7` (Windows), `F7` (macOS), `F7` (IntelliJ IDEA Classic (macOS)), `⌘ ]` (macOS System Shortcuts), `F7` (XWin), `F7` (GNOME), `F7` (KDE), `F7` (Emacs), `F7` (Sublime Text), `F7` (Sublime Text (macOS)), `F7` (NetBeans), `F7` (Visual Studio), `F7` (Visual Studio (macOS)), `Ctrl+F7` (Eclipse), `⌃ F7` (Eclipse (macOS)) |    Jump to the next or previous difference.       When the last or the first difference is reached, IntelliJ IDEA suggests clicking the arrow buttons or pressing `F7` (Windows), `F7` (macOS), `F7` (IntelliJ IDEA Classic (macOS)), `⌘ ]` (macOS System Shortcuts), `F7` (XWin), `F7` (GNOME), `F7` (KDE), `F7` (Emacs), `F7` (Sublime Text), `F7` (Sublime Text (macOS)), `F7` (NetBeans), `F7` (Visual Studio), `F7` (Visual Studio (macOS)), `Ctrl+F7` (Eclipse), `⌃ F7` (Eclipse (macOS))/`Shift+F7` (Windows), `⇧ F7` (macOS), `⇧ F7` (IntelliJ IDEA Classic (macOS)), `⌘ [` (macOS System Shortcuts), `Shift+F7` (XWin), `Shift+F7` (GNOME), `Shift+F7` (KDE), `Shift+F7` (Emacs), `Shift+F7` (Sublime Text), `⇧ F7` (Sublime Text (macOS)), `Shift+F7` (NetBeans), `Shift+F7` (Visual Studio), `⇧ F7` (Visual Studio (macOS)), `Shift+F7` (Eclipse), `⇧ F7` (Eclipse (macOS)) once more and comparing other files modified locally. This behavior depends on the [Go to the next file after reaching last change](settings-tools-diff-and-merge.html#last_diff) option in the [Diff Viewer settings](settings-tools-diff-and-merge.html).     |
|     ![the Compare Previous File icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.left.svg)       ![the Compare Next File icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.right.svg)     |    Compare Previous/Next File   `Alt+Left` (Windows), `⌘ ⇧ [` (macOS), `⌃ ←` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ ←` (macOS System Shortcuts), `Alt+Left` (XWin), `Alt+Left` (GNOME), `Alt+Left` (KDE), `Alt+Left` (Emacs), `Ctrl+Page Up` (Sublime Text), `⌘ ⇧ [` (Sublime Text (macOS)), `Ctrl+Page Up` (NetBeans), `Alt+Left` (Visual Studio), `⌘ ⇧ [` (Visual Studio (macOS)), `Ctrl+Shift+F6` (Eclipse), `⌘ ⇧ F6` (Eclipse (macOS))`Alt+Right` (Windows), `⌘ ⇧ ]` (macOS), `⌃ →` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ →` (macOS System Shortcuts), `Alt+Right` (XWin), `Alt+Right` (GNOME), `Alt+Right` (KDE), `Alt+Right` (Emacs), `Ctrl+Page Down` (Sublime Text), `⌘ ⇧ ]` (Sublime Text (macOS)), `Ctrl+Page Down` (NetBeans), `Alt+Right` (Visual Studio), `⌘ ⇧ ]` (Visual Studio (macOS)), `Ctrl+F6` (Eclipse), `⌘ F6` (Eclipse (macOS)) |    Compare the local copy of the previous or next file with its update from the server.      > **Note:** > These controls are only available if more than one file has been modified locally.     |
|  ![the Jump to Source button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.edit.svg)  |    Jump to Source   `F4` (Windows), `⌘ ↓` (macOS), `F4` (IntelliJ IDEA Classic (macOS)), `F4` (macOS System Shortcuts), `F4` (XWin), `F4` (GNOME), `F4` (KDE), `F4` (Emacs), `F4` (Sublime Text), `F4` (Sublime Text (macOS)), `F4` (NetBeans), `F4` (Visual Studio), `⌘ ↓` (Visual Studio (macOS)), `F12` (Eclipse), `F3` (Eclipse (macOS))  |  Open the selected file in the editor. The caret is placed in the same position as in the Diff Viewer.  |
|  ![the Collapse Unchanged Fragments icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.collapseAll.svg)  | Collapse Unchanged Fragments | Collapse all the unchanged fragments in both files. The number of non-collapsible unchanged lines is configurable on the Diff & Merge settings page. To open the Diff & Merge page, open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Tools \| Diff & Merge`. .  |
|     Side-by-side viewer  / Unified viewer      |     Select a viewer mode: side-by-side or unified. The side-by-side mode has two panels, and the unified mode has one panel.       You can edit code and perform the Accept, Append, Revert actions in both viewers.     You can change text only in the right part of the side-by-side viewer or in the lower line in the unified viewer.     You can edit only local versions of your files. You cannot edit files that have read-only status.    |
|  ![the Settings button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.settings.svg) | Settings |    Some of these commands are also available from the context menu of the Diff Viewer gutter.       Align Changes in Side-by-Side Diff: vertically aligns the corresponding lines by padding differences with empty space.       Synchronize Scrolling: scroll both diff panes simultaneously.       Show Diff in Editor Tab: displays the Diff viewer as an editor tab instead of a separate window.       Show Diff in Separate Window: displays the Diff viewer as a separate window instead of an editor tab.       Ignore Differences: define how the Diff Viewer should treat whitespaces.        * None: white spaces are important, and all the differences are highlighted. This option is selected by default.    * Trim whitespaces: trim whitespaces if they appear in the end and at the beginning of a line (`("\t", " ")`). * If two lines differ in trailing whitespaces only, these lines are considered equal. * If two lines are different, trailing whitespaces are not highlighted in the [By word](#highlight) mode.    * Ignore whitespaces: white spaces are not important, regardless of their location in the source code.    * Ignore whitespaces and empty lines: ignores 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 that consist of splitting or joining lines without changes to non-whitespace parts. For example, differences between `a b c` and `a \n b c` are not highlighted in this mode.    * Ignore imports and formatting: changes within import statements and whitespaces are ignored (whitespaces within String literals are respected though).      Highlighting Differences: select the way differences granularity is highlighted.        * Words: modified words are highlighted    * Lines: modified lines are highlighted    * Split changes: if this option is selected, big changes are split into smaller changes. For example, `A \n B` and `A X \n B X` are treated as two changes instead of one.    * Characters: modified symbols are highlighted    * None: if this option is selected, the differences are not highlighted at all. Use the None option when you work with the files that were significantly modified. In such cases, highlighting might introduce additional difficulties during a review.    |
|  ![the Help icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.help.svg)  |    Help   `F1` (Windows), `⌘ ⇧ F1` (macOS), `F1` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ F1` (macOS System Shortcuts), `F1` (XWin), `F1` (GNOME), `F1` (KDE), `F1` (Emacs), `F1` (Sublime Text), `⌘ ⇧ F1` (Sublime Text (macOS)), `F1` (NetBeans), `F1` (Visual Studio), `F1` (Visual Studio (macOS)), `F1` (Eclipse), `⌘ ⇧ F1` (Eclipse (macOS))  | Open a browser and show the corresponding help page. |
|  | `Ctrl+Shift+Tab` (Windows), `⌃ ⇧ ⇥` (macOS), `⌃ ⇧ ⇥` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ ⇥` (macOS System Shortcuts), `Ctrl+Shift+Tab` (XWin), `Ctrl+Shift+Tab` (GNOME), `Ctrl+Shift+Tab` (KDE), `Ctrl+Shift+Tab` (Emacs), `Ctrl+Shift+Tab` (Sublime Text), `⌃ ⇧ ⇥` (Sublime Text (macOS)), `Ctrl+Shift+Tab` (NetBeans), `Ctrl+Shift+Tab` (Visual Studio), `⌃ ⇧ ⇥` (Visual Studio (macOS)), `Ctrl+Shift+Tab` (Eclipse), `⌃ ⇧ ⇥` (Eclipse (macOS)) | Switch between the panes of the Diff Viewer. The active pane has the caret. |
|  ![apply left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.arrowRight%4014x14.svg) ![apply right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.arrow%4014x14.svg)  | Accept |    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 ![apply left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.arrowRight%4014x14.svg) and ![apply right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.arrow%4014x14.svg) to apply changes. This behavior is the default one.    * Press `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (NetBeans), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)) to change ![apply left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.arrowRight%4014x14.svg) or ![apply right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.arrow%4014x14.svg) to ![chevron button bottom right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.arrowRightDown%4014x14.svg) or ![chevron button bottom left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.arrowLeftDown%4014x14.svg) and append changes.    |
| Merge actions |
|  ![the Compare Contents icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.vcs.diff.svg) |  Compare Contents  |    Click this icon to invoke the list of options allowing you to compare different versions of a file to resolve a conflict.     Note that Base refers to the file version that the local and the repository versions originated from (initially displayed in the middle pane), while Middle refers to the resulting version.  |
|  ![the Apply Non-Conflicting Changes button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.applyNotConflicts.svg)  | Apply All Non-Conflicting Changes | Click this button to apply all non-conflicting changes. You can also make this behavior automatic by selecting the checkbox Automatically apply non-conflicting changes in the Diff & Merge page of the Settings dialog.  |
|  ![Apply Non-Conflicting Changes from the Left Side](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.applyNotConflictsLeft.svg) ![Apply Non-Conflicting Changes from the Right Side](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.applyNotConflictsRight.svg)  | Apply Non-Conflicting Changes from the Left/Right Side | Click these buttons to merge non-conflicting changes from the left/right parts of the dialog. |
|  ![the Resolve Simple Conflicts icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.diff.magicResolveToolbar.svg)  | Resolve Simple Conflicts |     Click this button to resolve simple conflicts (for example, if the beginning and the end of the same line have been modified in different file revisions) and merging the changes.       Such conflicts are not resolved with the Apply non-conflicting changes actions since you have to make sure that they are resolved properly.     |
|  |  Annotate with GitBlame  |     This option is only available from the context menu of the gutter.       Use this option to explore who introduced which changes to the repository version of the file and when. The annotations view lets you see detailed information for each line of code, such as the version from which this line originated, the ID of the user who committed this line, and the commit date.       For more information about annotations, refer to [Locate code author (Annotate with Git Blame)](investigate-changes.html#annotate_blame).     |

## Keyboard shortcuts

| Keyboard shortcut | Description |
| --- | --- |
| `Ctrl+Shift+D` (Windows), `⌘ ⇧ D` (macOS), `⌘ ⇧ D` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ D` (macOS System Shortcuts), `Ctrl+Shift+D` (XWin), `Ctrl+Shift+D` (GNOME), `Ctrl+Shift+D` (KDE), `Ctrl+Shift+D` (Emacs), `Ctrl+Shift+D` (Sublime Text), `Ctrl+Shift+D` (Sublime Text (macOS)), `Ctrl+Shift+D` (NetBeans), `Ctrl+Shift+D` (Visual Studio), `⌘ ⇧ D` (Visual Studio (macOS)), `Ctrl+Shift+D` (Eclipse), `⌘ ⇧ D` (Eclipse (macOS)) | Use this keyboard shortcut to show the popup menu of the most commonly used diff commands. |
| `Ctrl+Shift+Tab` (Windows), `⌃ ⇧ ⇥` (macOS), `⌃ ⇧ ⇥` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ ⇥` (macOS System Shortcuts), `Ctrl+Shift+Tab` (XWin), `Ctrl+Shift+Tab` (GNOME), `Ctrl+Shift+Tab` (KDE), `Ctrl+Shift+Tab` (Emacs), `Ctrl+Shift+Tab` (Sublime Text), `⌃ ⇧ ⇥` (Sublime Text (macOS)), `Ctrl+Shift+Tab` (NetBeans), `Ctrl+Shift+Tab` (Visual Studio), `⌃ ⇧ ⇥` (Visual Studio (macOS)), `Ctrl+Shift+Tab` (Eclipse), `⌃ ⇧ ⇥` (Eclipse (macOS))  | Use this keyboard shortcut to switch between the left and the right panes. |
| `Ctrl+Z` (Windows), `⌘ Z` (macOS), `⌘ Z` (IntelliJ IDEA Classic (macOS)), `⌘ Z` (macOS System Shortcuts), `Ctrl+Z` (XWin), `Ctrl+Z` (GNOME), `Ctrl+Z` (KDE), `Ctrl+Shift+Minus` (Emacs), `Ctrl+Z` (Sublime Text), `⌘ Z` (Sublime Text (macOS)), `Ctrl+Z` (NetBeans), `Ctrl+Z` (Visual Studio), `⌘ Z` (Visual Studio (macOS)), `Ctrl+Z` (Eclipse), `⌘ Z` (Eclipse (macOS))/`Ctrl+Shift+Z` (Windows), `⌘ ⇧ Z` (macOS), `⌘ ⇧ Z` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Z` (macOS System Shortcuts), `Ctrl+Shift+Z` (XWin), `Ctrl+Shift+Z` (GNOME), `Ctrl+Shift+Z` (KDE), `Ctrl+Shift+Z` (Emacs), `Ctrl+Shift+Z` (Sublime Text), `⌘ Y` (Sublime Text (macOS)), `Ctrl+Shift+Z` (NetBeans), `Ctrl+Y` (Visual Studio), `⌘ Y` (Visual Studio (macOS)), `Ctrl+Y` (Eclipse), `⌘ ⇧ Z` (Eclipse (macOS))  | 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:

| Item | Description |
| --- | --- |
| Annotate |    Enable this option to [annotate](investigate-changes.html#annotate_blame)  the changes.     > **Tip:** > This option is available only for the files under version control.    |
| Show Whitespaces | Enable this option to show whitespaces as the dots in the Diff Viewer. |
| Show Line Numbers | Enable this option to show line numbers in the Diff Viewer. |
| Show Indent Guides | Enable this option to have IntelliJ IDEA display vertical lines in the Diff Viewer to indicate positions of indents. |
| Soft-Wrap | Enable this option to have IntelliJ IDEA wrap the lines of code, when the dialog is resized. |
| Highlighting level | Use this menu item to select the highlighting level in the Diff Viewer. To learn more about the level of highlighting, refer to   [Change the highlighting level for a file](disabling-and-enabling-inspections.html#change-highlighting-level-for-file) .  |

This context menu is available in both editors:

| Item | Description |
| --- | --- |
| Annotate |    Enable this option to [annotate](investigate-changes.html#annotate_blame)  the changes.     > **Tip:** > This option is available only for the files under version control.    |
| Accept/Append | Select these commands to [accept or append](comparing-files-and-folders.html#twofiles) the lines shown in the Diff Viewer. |
| Compare with Clipboard | Select this command to compare the file in the respective pane of the Diff Viewer with the [contents of                             the Clipboard](comparing-files-and-folders.html#clipboard)  .  |
| Switch to Three-Side Viewer | This option is available only when you are comparing two files against each other. It allows you to load a third file and add it to the comparison. |

This context menu is available in the right-hand panel of the Diff Viewer:

| Item | Description |
| --- | --- |
| Go to high-priority problems only/Go to next problem | Click one of these radio-buttons to define the way of navigating between the encountered problems. |
| Customize highlighting level |  Click to show the slider to change the [highlighting level](disabling-and-enabling-inspections.html#change-highlighting-level-for-file) in the Diff Viewer.  |
| Show code lens on scrollbar hover |  Enables viewing code outside the visible area of the Diff Viewer when hovering over the scrollbar.  |

## How it works

* [Compare files, folders, and text sources](comparing-files-and-folders.html)

* [Resolve Git conflicts](resolve-conflicts.html)

* [Compare deployed files and folders with their local versions](comparing-deployed-files-and-folders-with-their-local-versions.html)

* [Compare files from the command line](command-line-differences-viewer.html)

* [Merge files from the command line](command-line-merge-tool.html)

