Reputation: 6603
I use VSCode as my default tool to compare files (git changes and others) and I sometimes I need to see the differences in the other way than I have them opened in the viewer.
For example, suppose I have the following comparison
And I want them to be shown the other way around like Doc2 <-> Doc1
Is there a way to easily do this without closing the current comparison and opening a new one in the other order?
Anything would work, it can be a shortcut (the ideal option) or a button that I can press which I am currently missing.
Upvotes: 21
Views: 7561
Reputation: 129
This is a thing now as of 1.86, see the accepted answer
2021:
You currently can't do this (version 1.54), but it has been suggested here on the github.
There is an extension for this here.
Upvotes: 12
Reputation: 50024
This is supported in VS Code 1.86. You can use Compare: Swap Left and Right Editor Side
in the command palette.
If you want to bind it to a keyboard shortcut, the command's ID is workbench.action.compareEditor.swapSides
. See also the isInDiffEditor
context key.
If you're interested in the history, see Allow to swap left and right hand side in diff editor #20958.
Upvotes: 17
Reputation: 2911
There is no option yet to swap files but for other readers it would be helpful to know that the order in which you selected the files in the Explorer matters.
Lets say there are 2 files "file1" and "file2"
If you select file1 first and then file2 and then right click -> compare selected then file1 is on the left and file2 is on the right.
If you select file2 first and then file1 and then right click -> compare selected then file2 is on the left and file1 is on the right.
Upvotes: 8