visual-studio-codecomparison

Is there a way to switch the compare direction with VS Code?


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

enter image description here

And I want them to be shown the other way around like Doc2 <-> Doc1

enter image description here

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.


Solution

  • 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.