Is there a Compare feature like the Plugin for Notepad++?
-
2Yes, there is, but it is integrated with the version control tools, you can't really ask it to compare two arbitrary files, but you can ask version control to compare two revisions of the same file, or your current file in the working folder with the last checked in / committed revision.Lasse V. Karlsen– Lasse V. Karlsen2015-05-09 13:01:48 +00:00Commented May 9, 2015 at 13:01
-
20@lasse vscode can compare two arbitrary files now. See my answer stackoverflow.com/a/45091703/1081043wisbucky– wisbucky2017-07-13 22:13:11 +00:00Commented Jul 13, 2017 at 22:13
-
3What plugin is "that" plugin??hippietrail– hippietrail2024-02-17 06:09:19 +00:00Commented Feb 17, 2024 at 6:09
-
If you want to edit both files you're comparing, you have to compare in split view. You can't edit the "red" in inline view. This is a bug: github.com/microsoft/vscode/issues/237270Daniel Kaplan– Daniel Kaplan2025-01-05 20:56:13 +00:00Commented Jan 5 at 20:56
18 Answers
in Explorer window, Right-Click on first file and select:

then Right-Click on second file and select:

Screencast:
13 Comments
You can compare files from the explorer either from the working files section or the folder section. You can also trigger the global compare action from the command palette.
8 Comments
code -d <file 1> <file 2> these days.I have Visual Studio Code version 1.27.2 and can do this:
Compare two files
- Drag and drop the two files into Visual Studio Code

- Select both files and select Select for Compare from the context menu

- Then you see the diff

- With Alt+F5 you can jump to the next diff

Compare two in-memory documents or tabs
Sometimes, you don't have two files but want to copy text from somewhere and do a quick diff without having to save the contents to files first. Then you can do this:
- Open two tabs by hitting Ctrl+N twice:

- Paste your first text sample from the clipboard to the first tab and the second text sample from the clipboard to the second tab
- In the "Open Editors" view, select the first document Untitled-1 with Select for Compare:

- Select the second document Untitled-2 with Compare with Selected:

- Then you see the diff:

6 Comments
pip list, in Windows, without all the bash goodies. It's either this or... nothing. Thank you #Lernkurve!Here is my favorite way, which I think is a little less tedious than the "Select for Compare, then Compare With..." steps.
Open the starting file
Open the Command Palette (F1 or Ctrl + Shift + P)
Type
Compare Active Fileand selectCompare Active File With...Select the new file to compare with. You can either select a recent file from the dropdown list, or click any file in the Explorer panel.
View the Result!
Note: This works with any arbitrary files, even ones that are not in the project dir. You can even just create 2 new Untitled files and copy/paste text in there too.
8 Comments
Another option is using command line:
code -d left.txt right.txt
Note: You may need to add code to your path first. See: How to call VS Code Editor from terminal / command line
2 Comments
In your terminal type:
code --diff file1.txt file2.txt
A tab will open up in VS Code showing the differences in the two files.
1 Comment
There is plugin called Partial Diff which helps to compare text selections within a file, across different files, or to the clipboard.
4 Comments
Quickly open - and close - 2 new empty editors for a compare
As of Insiders Build v1.75, there is a new command to quickly open 2 new (i.e., empty) editors for a diff/compare. Into each of these you can paste whatever you want to compare between them. The command is:
File: Compare New Untitled Text Files
workbench.files.action.compareNewUntitledTextFiles
There is no default keybinding. Demo:
4 Comments
Recently I created a VSCode extension for even faster way of file comparison. It's called Fast Compare and you can download it here.
https://marketplace.visualstudio.com/items?itemName=DavidKol.fastcompare
Comments
If you want to compare file in your project/directory with an external file (which is by the way the most common way I used to compare files) you can easily drag and drop the external file into the editor's tab and just use the command: "Compare Active File With..." on one of them selecting the other one in the newly popped up choice window. That seems to be the fastest way.
Comments
I found a flow which is fastest for me, by first associating a keyboard shortcut Alt+k to "Compare Active File With..." (#a). (Similar to wisbucky's answer but further improved and more step-wise.)
Then, to compare two files:
- Open or focus file B (will be editable in compare view by default). E.g. by drag-drop from File Explorer to VS Code's center.
- Open or focus file A.
- Press
Alt+k, a quick open menu will be shown with file B focused. - Press
Enter.
Result: file A on left and file B on right. (Tested on VS Code 1.27.1)
Remarks
#a - to do so, press Ctrl-k Ctrl-s to show Keyboard Shortcuts, type compare on the top search box, and double click the "Keybinding" column for "Compare Active File With...", press Alt+k then Enter to assign it.
1 Comment
If we are talking about about "features" per se, there are lots of features that can "replicate" the funcionalities that we are familiar with in Jetbrains.
Like so, there is one that I have found very interesting:
Once you installed it, you double-click and you have all sorts of functionalities to compare, for instance "with clipboard" without having to rely on "copy paste" that part of code in a new file.
Then when comparing with clipboard you should have sth like this:
Hope this helps
Comments
Here's a link to marketplace for extension. Extension "compareit" helps to compare two files wich you can choose from your current project and other directory on your computer or clipboard.
1 Comment
For comparing JSONFiles :
If you are willing to compare JSON file, maybe you want to add one more step in VSCode:
- Open the starting
JSON File 1 - Right click in the file area and select
Format Documentor pressCMD + Shift + Fon Mac - Open the Command Palette (
F1orCMD + Shift + Pon Mac) - Search/Select
Compare Active File with...selectJSON File 2 - You can select
Inline Viewfrom...menu
Note: All the steps mentioned above are same as all other answers except step-2 which is crucial for JSON file for better visibility.











