

You can right-click in your editor and select Local history → Show history. Comparing with the previous local version of the fileĮven if you're not using any Version Control system, IDEA stores historical versions of your local files. This opens a brand new diff window with both panels blank, so you can copy and paste both snippets to be compared. What about the case when you want to compare two non-file code snippets from external sources? You can do this too! Just run Find Action via Ctrl + Shift + A and then search for Open Blank Diff Window. If you want just a selection instead, select some fragment of the file first and then right-click as before. If you want the whole file to be compared, just right-click anywhere in the editor and select Compare with Clipboard from the context menu.

Either compare the whole file against the clipboard or just a selection. Then copy to clipboard the snipped you want to compare ( Ctrl+ C). Maybe it is a code snippet from the web, for example, from stack overflow.įirst, you need to open the file from your project in your editor.

Maybe you have a file in your project, and you need to compare it with some external content, which is not saved as a file on your machine. Now the comparison is the same as in the example above. The last step is to browse for an external file to compare with.

This is very similar to diff in Version Control Systems such as Git. Now the new window opens, which contains two panels, each with one file. Right click one of the files and select Compare Files.Just select both files in your project window (holding Ctrl for multi-selection). Let's say there are two similar files in your project, and you need to compare them line by line. IntelliJ IDEA offers numerous ways of comparing files, folders and code snippets and even synchronizing folder contents.
