4

My Python docstrings & block comments in Visual Studio Code always used to be a different color to the single line comment. They use to be:

  • docstrings & block comments: orange
  • single line comments: green

I did a reinstall of Visual Studio Code this morning and the block comments and docstrings are now the same color as the single line comments (so all comments are green).

I have pasted an image (in case the colors here are different).

enter image description here

I have always used the default dark mode (and never change the default settings). Has something changed or is there a setting that could change this back?

Timothy G.
  • 6,335
  • 7
  • 30
  • 46
D.L
  • 4,339
  • 5
  • 22
  • 45
  • 3
    I actually found a dupe: [Restarted Visual Studio Code, and now Python docstrings are colored like comments. How do I return it to the string color?](https://stackoverflow.com/questions/76436694/restarted-visual-studio-code-and-now-python-docstrings-are-colored-like-comment) – Timothy G. Jun 13 '23 at 16:24
  • 3
    noted. the question here is much clearer and with image illustrating and a more concise answer. So i prefer this. I also disagree with the premise of the other question and would agree that the VScode method (ie. same colors) is better. Also, this question does **not** seek to change the new default settings. – D.L Jun 13 '23 at 21:07
  • 1
    [1/2] @D.L., since you _like_ this change of docstrings now being colored the same as comments instead of strings, I recommend you go leave a comment and add some reactions to comments to make your voice heard [here (this is a PR trying to revert the change to go back to the old behavior)](https://github.com/microsoft/vscode/pull/184938), [here (this is an issue trying to revert the change)](https://github.com/microsoft/vscode/issues/184836)... – Gabriel Staples Jul 09 '23 at 15:56
  • [2/2]...and [here (this is my original PR that made the change, but has a _lot_ of antagonistic comments against it now, after the fact)](https://github.com/microsoft/vscode/pull/182162). There are a lot of people up in arms about this who are trying to undo the change, and I'm afraid that will then upset all those who really like this change but are saying nothing right now. So, I recommend you go say something. – Gabriel Staples Jul 09 '23 at 15:57
  • 1
    @GabrielStaples, i will do. i absolutely support this. I have got used to the change very quickly. I appreciate that change is hard for some people who are stuck with a system of their own... – D.L Jul 10 '23 at 06:45
  • Well, I'm happy that someone has liked it. But as for me it looks like - ok all the traffic lights yesterday were green and red. So why don't just invert these colors for today? Or your car yesterday was black and today it's pink. Or steering wheel yesterday was on the right side and now it's on the lift side. Why not? Why not to add custom/new theme Dark++ and announce it. Why it was actually required to change the default appearance? Let's make all the comment letters dark-green on the black background. Such a lovely idea! – SmartWaddles Aug 02 '23 at 11:09

2 Answers2

5

According to the Release notes for 1.79 (the pull request section), they changed the docstring comment colors with this pull request.

You can set your own colors for this using the solution in the other answer.

Timothy G.
  • 6,335
  • 7
  • 30
  • 46
  • 1
    thank you for pointing this out. I see that the folk at `vscode` have done this for good reason... – D.L Jun 13 '23 at 16:24
  • 1
    For anyone who wants to undo this change and go back to having docstrings be the same color as strings instead of comments, see [the two answers here, including mine](https://stackoverflow.com/q/76436694/4561887). – Gabriel Staples Jul 09 '23 at 15:42
  • 1
    [1/2] For anyone who _likes_ this change of docstrings now being colored the same as comments instead of strings, please go leave a comment and add some reactions to comments to make your voice heard [here (this is a PR trying to revert the change to go back to the old behavior)](https://github.com/microsoft/vscode/pull/184938), [here (this is an issue trying to revert the change)](https://github.com/microsoft/vscode/issues/184836)... – Gabriel Staples Jul 09 '23 at 15:51
  • 1
    [2/2]...and [here (this is my original PR that made the change, but has a _lot_ of antagonistic comments against it now, after the fact)](https://github.com/microsoft/vscode/pull/182162). There are a lot of people up in arms about this who are trying to undo the change, and I'm afraid that will then upset all those who really like this change but are saying nothing right now. So, go say something. – Gabriel Staples Jul 09 '23 at 15:51
  • 1
    I support the change in colour, it makes perfect sense, and here is why: https://github.com/microsoft/vscode/pull/184938 – D.L Jul 10 '23 at 06:53
2

Open your settings.json file, paste these lines, and modify them to your taste:

{
    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "string.quoted.docstring.multi.python",
                "settings": {
                    "foreground": "#FFA500" // Change this to your preferred colour for docstrings and block comments
                }
            }
        ],
        "comments": "#008000" // Change this to your preferred colour for single-line comments
    }
}

Make sure to fit them properly with other rules if there are any (e.g. not forgetting commas).

AbdelRahman
  • 242
  • 10
  • 2
    To add, according to the Release notes for 1.79 (the [pull request section](https://code.visualstudio.com/updates/v1_79#_pull-requests)), they changed the docstring comment colors with [this pull request](https://github.com/microsoft/vscode/pull/182162). – Timothy G. Jun 13 '23 at 15:31
  • @TimothyG. Good catch! – AbdelRahman Jun 13 '23 at 15:35
  • @TimothyG. if the colours are changed as per the link you sent *"treat comment docstrings as comments too"*, then this best answers my question. i will stick to the VS code defaults. I have therefore upvoted the comment. – D.L Jun 13 '23 at 15:58