3

Is there an extension or setting, which makes a file with a .diff extension, opened in VS Code, display added lines in green and deleted lines in red? Currently, when I open a diff file, it displays added and deleted lines in the same color. I'm using VS Code Version: 1.37.1.

P.S. I tried the diff extension, but it doesn't work for me.

P.P.S. I tried reloading VS Code with extensions disabled and the highlighting is still broken:

enter image description here

3
  • So you're talking about the background color? Because otherwise that's red and green as expected. Commented Aug 22, 2019 at 12:00
  • @Gama11 you mean the color of the + and -? Because I expect that the whole line is highlighted in green or red. Commented Aug 22, 2019 at 12:17
  • Did you resolve this issue? Commented Apr 13, 2022 at 9:48

3 Answers 3

10

I observed that .diff files are highlighted by default(without requiring any extensions), it's just that certain themes do not work well. Theme-Winter is coming

Theme-Dracula at night

Sign up to request clarification or add additional context in comments.

Comments

2

VS Code currently have this feature, if you get the .diff extension the sintax highlight performs correctly like git bash.

My VS Code is:

Version: 1.47.2 (system setup)
Commit: 17299e413d5590b14ab0340ea477cdd86ff13daf
Date: 2020-07-15T18:22:06.216Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 6.3.9600

Comments

1

Adding syntax highlighting overrides can fix this on themes where diff doesn't work:

ctrl+shift+p: Open User Settings (JSON)

    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "markup.deleted",
                "settings": {
                    "foreground": "#FF0000",
                },
            },
            {
                "scope": "markup.inserted",
                "settings": {
                    "foreground": "#00FF00",
                },
            },
        ],
    },

(Token scopes can be found by ctrl+shift+p: Inspect tokens and scopes)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.