8

When git shows the diff between two versions, it has the ability to show sections that have moved (as opposed to just added or removed) in a particular color, using the colorMoved = default config option.

In Visual Studio Code the command Git: Open Changes seems to ignore this option. Is it possible to make Code show what lines have moved?

I've looked at the color settings in https://code.visualstudio.com/api/references/theme-color#diff-editor-colors but couldn't find anything there.

4 Answers 4

6
+300

It is simply not implemented (which can change in the future). If you check the source code it is not mentioned anywhere.

Here is the code which colors the diff editor colors.

1

In VS Code 1.82, you can opt into the new experimental moved code detection by setting diffEditor.experimental.showMoves to true in your settings. Quoting from the 1.82 release notes:

When enabled, code blocks that are moved from one location to a different location in the same file are detected and arrows are drawn to indicate where the code blocks moved to.

Code moves are also detected when they are slightly modified. The Compare button can be used to compare the block before and after the move.

1

I am working on a Visual Studio Code extension called SemanticDiff that can highlight moved code blocks in diffs. It looks like this:

Moved Code in SemanticDiff

It only works with certain programming languages, as it parses the code to also detect moves that contain minor code changes. You can find the list of supported languages and how to install the extension on the SemanticDiff VS Code marketplace page.

1

Recently implemented feature of VS Code, you need only enable it in the VS Code settings.

Not the answer you're looking for? Browse other questions tagged or ask your own question.