VS Code: How to Compare Two Files (Find the Difference)
( 24 Articles)
This article shows you a couple of different ways to compare two files by using VS Code (Visual Studio Code). The first approach is to use your mouse and the second one is to use the command line.
Using Your Mouse
1. Select the two files you want to compare (see the diff), right-click, and select “Compare Selected” from the drop-down menu.
2. The difference will be highlighted as below:
Using Command Line
The command that can be used to check the diff between two files:
code --diff [path to file 1] [path to file 2]
When you run the command above, you may run into this error:
command not found: code
Solution: Open Command Palette (press “Command” + “Shift” + “P” on Mac and “Ctrl” + “Shift” + “P” on Windows), search for “install code” and select “Shell Command: Install ‘code’ command in PATH”:
And you will see this:
code --diff ./lib/main.dart ./lib/draft.dart
We’ve gone through two different ways to check the difference between two files by using VS Code. If you’d like to explore more about this awesome IDE, take a look at the following articles:
- VS Code: 3 Ways to Change Terminal Font SIze
- VS Code: Hide Specific Files/Folders from the Left SIdebar
- VS Code: How to Use Custom Settings for a Project
- VS Code: How to Hide/Show the Mini Map
- VS Code: How to Disable/Enable Suggestions on Hover
You can also check our VS Code topic page for the latest guides, tips, and tricks.