Search code examples
gitvisual-studio-codediff

How to color moved lines in git diff in Visual Studio Code


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.


Solution

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