VS Code: How to Compare Two Files (Find the Difference)

Updated: September 3, 2023 By: A Goodman One comment

This concise and straightforward article shows you a couple of different ways to compare two files 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. Hold the Ctrl key (if you’re using Windows) or the Command key (if you’re on a Mac) and select the two files you want to compare with your mouse, right-click, then select “Compare Selected” from the drop-down menu. See the screenshot below to get a better understanding:

2. The difference will be highlighted as follows:

The animated GIF below clearly tells what I mean:

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

The result:


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 excellent IDE, take a look at the following articles:

You can also check our VS Code topic page for the latest guides, tips, and tricks.

Notify of
1 Comment
Inline Feedbacks
View all comments
1 year ago


Related Articles