CLion 2018.1 Help

Comparing Files and Folders

CLion lets you review the differences between files, folders, and database objects, as well as between local files and their repository versions.

Comparing files

You can compare:

CLion displays the differences in the Differences Viewer for Files:

cl compareFiles

You can apply changes using the chevron buttons icon InsertReplaceicon InsertReplace2.

To append changes, press Ctrl (for Windows and Linux) or (for macOS): the icon InsertReplaceicon InsertReplace2 buttons will turn to append changes icon rightappend changes icon left.

Compare two files

  1. Select the files you want to compare in the Project tool window.
  2. On the context menu, choose Compare Files, or press Ctrl+D.

Compare active editor with Clipboard

  • Right-click anywhere in the editor and choose Compare with Clipboard from the context menu.

Compare active editor with a project file

  1. Right-click the file you want to compare with the currently opened file in the Project tool window.
  2. Choose Compare File with Editor from the context menu.

Compare active editor with any file

If you often need to compare files that are outside your project with the active editor, or don't want to have the Project tool window open, you can use the Compare File with Editor option that lets you choose any file and compare it with the active editor.

To add this action to the editor tab's context menu:

  1. Press Ctrl+Alt+S or choose File | Settings (for Windows and Linux) or CLion | Preferences (for macOS) from the main menu, and then go to Appearance & Behavior | Menus and Toolbars.
  2. In the right pane, expand the Editor Tab Popup Menu node, click Add After, and choose the Compare File with Editor action under Version Control Systems | Diff & Merge.

Compare a local file with its repository version

  1. Select a modified file anywhere in the Version Control tool window.
  2. Click the compareIcon icon on the toolbar or press Ctrl+D.

Comparing folders

CLion allows you to compare files in two folders against their file size, content, or timestamp. The differences are displayed in the Differences Viewer for Folders:

cl compareFolders

The top pane lists all files in the selected folders, while the bottom pane shows the differences between two versions of the selected file (see Comparing Files and Folders).

Compare folders

  1. Select the folders you want to compare in the Project tool window.
  2. On the context menu, choose Compare Directories, or press Ctrl+D.
  3. Use the following toolbar buttons to filter the list:
    • arrow right: click to display files that are present in the left folder, but are missing form the right one.
    • arrow left: click to display files that are present in the right folder, but are missing from the left one.
    • not equal: click to display files that are present in both folders, but whose contents, timestamp or size are different.
    • equal: click to display files that are present in both folders and that are identical with regard to the option selected in the Compare by dropdown.

Synchronize folders

CLion lets you sync the contents of two folders, or apply changes from one folder to another.

  1. For each file, click the icon in the * column until you've set an action to be taken on that file.
    • arrow right: copy the selected item from the left to the right folder. If such file already exists in the right folder, it will be overwritten.
    • arrow left: copy the selected item from the right to the left folder. If such file already exists in the left folder, it will be overwritten.
    • equal: no action will be performed (the two files are identical).
    • not equal: no action will be performed (the two files are different).
    • close.png: remove the selected item.
  2. Do one of the following:
    • To apply the selected action to the current item, click the Synchronize Selected button debug resume on the toolbar.
    • To apply the selected actions to all items, click the Synchronize All button rerun on the toolbar.

Compare different files in two folders

Sometimes a file may be present in one folder, and another file with a similar name in the other folder (for example, VCS_library_1.4 and VCS_library_1.5). These may be versions of the same file that you want to compare. Also, there may be a situation when you think a file was renamed, but is otherwise identical to a file in another folder. CLion lets you compare two files, one of which is present in the right folder, and another one in the left even though such files are treated as different entities:

  1. Select the files you want to compare in the left and the right pane.
  2. Click the Compare New Files with Each Other icon compare new files icon on the toolbar. The differences between the selected files will be displayed in the bottom pane.
Last modified: 22 May 2018

See Also