Open VS Code with the files you are going to compare. Right-Click one file you want to compare => Select for Compare.
When comparing Notepad++ vs Visual Studio Code, the Slant community recommends Visual Studio Code for most people. In the question“What are the best programming text editors?” Visual Studio Code is ranked 3rd while Notepad++ is ranked 12th.
locate the required file in the Solution Explorer window, right-click it and choose Compare Selected File in the context menu; open the required file in Visual Studio, right-click the required document name in the document tab well and in the document's context menu select Compare Current File.
right click on first file and select
then right click on second file and select
Screencast:
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.
I have Visual Studio Code version 1.27.2 and can do this:
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:
Here is my favorite way, which I think is a little less tedious than the "Select for Compare, then Compare With..." steps.
F1
Compare Active File With...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.
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 command line
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With