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:
- Open both the files in VS Code.
- From the left Explorer panel, right-click the first file and choose "Select for Compare" from the right-click menu.
- Then right-click the second file and choose Compare with Selected.
- 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.
- Open VS Code
- Launch Terminal (Click on "Terminal" -> "New Terminal")
- Then use below code
code -d sampleText.txt sampleTextNew.txt?
- 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