In this article, I have mentioned how we can compare two files side by side using Visual Studio(VS) Code, as it is very common to check file or code difference between 2 files in Visual Studio Code.

So here are the steps to compare two (2) files in Visual Studio(VS) Code, I will be comparing 2 text files in this example, but you can text Code files also:

  1. Open both the files in VS Code.
  2. From the left Explorer panel, right-click the first file and choose "Select for Compare" from the right-click menu.
  3. Then right-click the second file and choose Compare with Selected.
  4. Both the files will be opened in the main panel, side by side and you will see difference between both files as "+" or "-" sign. For example, I compared 2 text files and here is output

Using Command Line

If you have Visual Studio Code installed, you can compare 2 files using the Command line.

  1. Open VS Code
  2. Launch Terminal (Click on "Terminal" -> "New Terminal")
  3. Then use below code
    code -d sampleText.txt sampleTextNew.txt?
  4. This will open the main panel and show the difference between both files.

That's it.

You may also like to read:

How to comment multiple lines in Visual Studio (VS) Code

Show tabs and spaces in Visual studio code

Check Visual Studio version OR VS Code version

How to create .pfx file from certificate and private key

Run CMD Command Using Powershell

How do i format or beautify code in Visual Studio code?