Is there a Compare feature like the Plugin for Notepad++?
This question is related to
visual-studio-code
Here's a link to marketplace for extension. Extension "compareit" helps to compare two files wich you can choose from your current project and other directory on your computer or clipboard.
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.
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.
I found a flow which is fastest for me, by first associating a keyboard shortcut Alt+k
to "Compare Active File With..." (#a). (Similar to wisbucky's answer but further improved and more step-wise.)
Then, to compare two files:
Alt+k
, a quick open menu will be shown with file B focused.Enter
.Result: file A on left and file B on right. (Tested on VS Code 1.27.1)
#a - to do so, press Ctrl-k Ctrl-s
to show Keyboard Shortcuts, type compare
on the top search box, and double click the "Keybinding" column for "Compare Active File With...", press Alt+k
then Enter
to assign it.
If you want to compare file in your project/directory with an external file (which is by the way the most common way I used to compare files) you can easily drag and drop the external file into the editor's tab and just use the command: "Compare Active File With..." on one of them selecting the other one in the newly popped up choice window. That seems to be the fastest way.
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:
There is plugin called Partial Diff which helps to compare text selections within a file, across different files, or to the clipboard.
Right click on 1st file click "Select for compare".
Click 2nd file click "Compare with selected"
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
Source: Stackoverflow.com