I\'m really liking the IntelliJ diff tool. I\'m wondering if it is possible to use this tool to diff two arbitrary files. I.e. files NOT in an IntelliJ project. Just pick tw
Just select both files in project structure and hit:
Windows: ctrl+D
Mac: command+D
Select 2 files in Project panel and press CTRL + D.
In IntelliJ IDEA 2018.2, you can open an empty Differences Viewer and paste any text you want to compare in its left and right panels. The new Open Blank Diff Viewer action can be found in the Find Action dialog.
From the terminal, you can use the idea launcher directly like so:
# Windows
idea.exe diff path1 path2
# MacOS/Linux
idea diff path1 path2
At least for MacOS (I'm not certain of Windows), if you've created the Command-line Launcher via "Tools -> Create Command-line Launcher..." it's as simple as the following:
# Create some files to diff
echo "This is line 1" > file1.txt
echo "This is line 2" > file2.txt
# Diff with IntelliJ
idea diff file1.txt file2.txt
Note this works with other JetBrains applications as well; for example, using WebStorm or PyCharm:
# Diff with WebStorm
webstorm diff file1.txt file2.txt
# Diff with PyCharm
charm diff file1.txt file2.txt
Reference
IntelliJ Idea 13 has a feature labeled Compare with Clipboard. This feature compares the current open file with a version that you have copied into your clipboard. It's a great, easy way to compare and merge two files easily. It can also be used to compare two arbitrary blocks of code. Can't figure out why one block works and another does not? Use this feature.
This option is present under View > Compare with Clipboard. I assigned an easy to remember keyboard shortcut to give me quick access to this feature.
Yes you can (of course, if we are talking about text
files). But probably you will need to create some project (just for opening there files).
Then your steps will be:
1) Add to created project file#1 and file#2.
2) Open file#1 in editor
3) Right click mouse in left menu (project files browser) on file#2 and find menu-item Compare File with Editor
.
That's all. After p.3) a comparison windows will be opened.