PyCharm 2021.1 Help

Duplicates tool window

View | Tool Windows | Duplicates

The Duplicates tool window displays the results of the search for duplicates.

Panes of the Duplicates tool window

The window consists of the following panes:

  • The left pane displays the tree view of the duplicate fragments of source code. Each node shows the following information:

    • The number of duplicated code fragments found in scope.

    • The 'cost' of the duplicate (which is an arbitrary unit calculated using an additive algorithm on the base of the code block size; generally, the larger is the code fragment, the higher is its cost).

    • The containing class where the duplicates are located.

  • The right pane shows the differences between the duplicated fragments of source code, selected in the left pane.

Left toolbar

ItemShortcutDescription
RerunRerunClick this button to rerun the duplicates analysis in the active tab.
CloseClose Active Tab
Ctrl+Shift+F4
Click this button to close the active tab.
Navigate with Single ClickNavigate with Single ClickIf the button is pressed, selecting an entry in the left pane opens the respective file in the editor.

Upper toolbar

ItemTooltip/Image/ShortcutDescription
Previous NextF7/ Shift+F7Move to the next/previous difference
Whitespace

Define how the differences viewer should treat whitespaces.

  • Do not ignore: 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 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 consisting 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.

Highlighting mode

Select the way differences granularity is highlighted.

The available options are:

  • Highlight words: modified words are highlighted

  • Highlight lines: modified lines are highlighted

  • Highlight 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.

  • Highlight symbols: modified symbols are highlighted

  • Do not highlight: if this option is selected, the differences are not highlighted at all.

    Use the Do not highlight option when you work with the files that were significantly modified. In such cases, highlighting might introduce additional difficulties during a review.

Edit

Jump to Source

F4
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 Duplicates tool window.
the Synchronize buttonSynchronize scrollingClick this button to scroll both differences panes simultaneously. If this button is released, each of the panes can be scrolled independently.
the Settings buttonSettings

Open a list of available settings.

These commands are also available from the context menu of the differences viewer gutter.

Context menu commands

ItemKeyboard ShortcutDescription
Jump to SourceF4Open in the editor the file that contains the selected duplicate, and place the caret at the beginning of the duplicate. The fragment of code is highlighted.
Show SourceCtrl+EnterOpen in the editor the file that contains the selected duplicate, and highlight the fragment of code.
Send to left/Send to rightUse these commands, or the arrow icons Show as left diff version and Show as right diff version to place the selected duplicate to the left or right pane of the differences viewer.
Last modified: 12 May 2021