4

I really like the V.S. Code theme, Abyss. On occasion I find that the theme makes my code difficult to read, the text rendered in the editor will look like it is blending into the background, therefore; I thought changing individual syntax color would be a good solution.

I want to be able to adjust a couple of color-tokens, while leaving the rest of the syntax unchanged. How can I select, and change the properties of color tokens, without impacting any other parts of the theme that's currently set in the editor?

enter image description here

I want to use the code syntax color of the GitHub dark default theme with the Abyss theme on the rest of UI.

enter image description here

I found a site (click to see) that suggests changing the syntax colors with the editor.tokenColorCustomizations property.

I am not able to understand that how can I copy the color configuration from GiHub dark default to the Abyss theme.

JΛYDΞV
  • 8,532
  • 3
  • 51
  • 77
Darkstar Dream
  • 1,649
  • 1
  • 12
  • 23

2 Answers2

4

V.S. Code users have the ability to style the syntax that is displayed in the editor, as well as the ability to style the editor its self — this includes the workbench, and all off the items in the workbench. To start styling the workbench, or syntax in the editor, you must first add the following JSON properties to either your user-scoped settings.json file, or by adding it to a workspace-scoped settings.json.


  • "workbench.colorCustomizations":{ /* properties here */ }
  • "editor.tokenColorCustomizations":[ /* properties here */ ]

Example of a properly configured settings.json file:

// "./.vscode/settings.json"
{
    "workbench.colorCustomizations": {
        "editor.background": "#08182F",
        "sideBar.background": "#00132D",
        "panel.background": "#00132D",
        "activityBar.background": "#002040",
        "editorGroupHeader.tabsBackground": "#00132D",
        "tab.inactiveBackground": "#00132D",
        "tab.activeBackground": "#003054",
        "tab.activeBorder": "#003054",
        "breadcrumb.background": "#003054",
        "statusBar.background": "#005280",
        "sideBar.border": "#103050",
        "titleBar.border": "#103050",
        "statusBar.border": "#103050",
        "menu.border": "#103050",
        "contrastBorder": "#103050",
        "panel.border": "#103050",
        "editorRuler.foreground": "#103050",
        "tab.border": "#103050",
        "tab.lastPinnedBorder": "#103050",
        "activityBar.border": "#103050",
    },

    "editor.tokenColorCustomizations": [
        {
            "scope": "punctuation",
            "settings": {
                "foreground": "#C4C4C4",
                "fontStyle": ""
            }
        },

        {
            "scope": "comment",
            "settings": {
                "foreground": "#246488",
                "fontStyle": ""
            }
        },

        {
            "scope": "string",
            "settings": {
                "foreground": "#98DAF4",
                "fontStyle": ""
            }
        },
    ]
}

There are many more properties that can be used to style your editor and syntax. A good resource to refer to is this template, its from the YO CODE generator, and it is what several theme designers use as a starting point when creating a new theme.


Theme Template (e.g. you don't have to make a theme to use the properties).


The most useful tool at your disposal is when writing theme properties — just like in the example above — is VSCodes suggestion widget. The suggestion widget is most often used to auto complete code, however, its usefulness extends much further than finishing a line of text for you. If you type, "background", while you are focused inside of one of the colors, or tokenColors, properties a whole list of available background properties will be available to choose from, and you are not limited to just background properties, the suggestion widget will work for finding borders, foregrounds, icons, buttons, inputs, bars, highlights and a whole lot more



Perhaps the best resource to read would be the VSCode Contributed Page on Color-Themes


EDIT: If you download the GitHub theme, you can find the theme's JSON file, which is the source code for the "Dark GitHub Theme" in the following location:

$HOME/.vscode/extensions/github.github-vscode-theme-4.1.1/themes/dark.json

When ever you have a theme's source JSON Document, you can copy and paste individual properties from the theme you located, into your ./.vscode/settings.json file using the properties:


  • "workbench.colorCustomizations":{ /* properties here */ }
  • "editor.tokenColorCustomizations":[ /* properties here */ ]


NOTE: It takes some practice, and some reading to get good at creating themes, or even just configuring your current theme to customize it a bit like your doing now.


ADDITIONAL HELP

I think it might help if I explain what it is your doing.

The workspace settings.json file, located in the root of each project...

"./.vscode/settings.json"

...takes precedence over all other configuration files, therefore, when a setting, or property is being configured in two files, and one of the files is "./.vscode/settings.json" then the configuration set inside "./.vscode/settings.json" will win-out the configuration in the other file, because "./.vscode/settings.json" overrides any configurations it holds, that are also held somewhere else. (I Hope that makes sense)...

Next to the workspace "settings.json" file, is the users settings.json file, which is located at:

"$HOME/.config/Code/User/settings.json"

So basically all you need to know at this point is your settings.json files are the word of the land, everything else is overridden. This is very important, because when you use the settings.json files to set color-token properties to highlight some syntax that is being colored by a theme, and your recoloring it because you don't like it, what you are doing, is overriding the theme's JSON file located in the themes extension directory @ $HOME/.vscode/extensions. If you don't set a property in a valid settings.json file, then the property will remain unchanged. This lets you select and choose which properties to change, by overriding the properties you don't like. And as I have stated in the comments and above, these are the properties you will use to preform the overrides.


  • "colors":{ /* properties here */ }
  • "tokenColors":[ /* properties here */ ]

Rather than trying to copy and paste entire themes, just try to change a single element. Once you succeed at changing one element, then you can try changing several in unison.

Dada
  • 6,313
  • 7
  • 24
  • 43
JΛYDΞV
  • 8,532
  • 3
  • 51
  • 77
  • I just want to change the code syntax highlighting colors. I don't know which color is used for what, and individually setting could be hard. So, I checked the source JSON file of the theme [Github Theme](https://github.com/primer/github-vscode-theme/blob/master/src/theme.js). I believe from line 226 they have mentioned the code for color property. So is there any way to copy that and paste it in my setting.json file. Actually I don't have much knowledge about JSON syntax so can you pls help me? – Darkstar Dream Jun 30 '21 at 00:21
  • The same way that you use "workbench.colorCustomizations" & "editor.tokenColorCustomizations" is the the same way you create a theme. So they are often cross referenced, but any of the token properties you can highlight in a theme you can highlight in the settings.json properties that I just mentioned. – JΛYDΞV Jun 30 '21 at 00:27
  • if you don't mind, then can you please look at my current [setting.json](https://gist.github.com/DarkstarDream/439bfbf6db008dadf430f76d64054ff8) file and can you tell me how I can add those code in my setting file – Darkstar Dream Jun 30 '21 at 00:34
  • Yes, I am going to add it into the answer because I markdown isn't supported in these comments. Gimme a minute – JΛYDΞV Jun 30 '21 at 00:35
  • @DarkstarDream Okay that's all your getting for now. Try and change stuff, if you cant maybe I can help more later. – JΛYDΞV Jun 30 '21 at 01:06
  • I copied the code as you suggested but it's to have no effect. The code that I copied into the setting.json looks faded in compared to other settings, I don't know what it means. Can you pls take look to my updated setting files and point out my mistake [setting.json](https://gist.github.com/DarkstarDream/439bfbf6db008dadf430f76d64054ff8/revisions) – Darkstar Dream Jun 30 '21 at 01:07
  • I sure hope you read everything I wrote, I took a lot of time to do that for you. I just posted it in my editor and it worked. Try opening up a brand new project, and the only thing you will place in the project is a directory. Name the directory `.vscode` with the dot in front of it. – JΛYDΞV Jun 30 '21 at 01:31
  • then add a file to the `.vscode` directory called settings.json – JΛYDΞV Jun 30 '21 at 01:32
  • so your files path will be `./.vscode/settings.json` – JΛYDΞV Jun 30 '21 at 01:33
  • Open up settings.json and post in the code from the snippet. – JΛYDΞV Jun 30 '21 at 01:33
  • I made a change to my snippet because I have a feeling you left out the curly braces last time you tried the code. Every-time you create a JSON file, add curly brackets to the file first like this `{ }`. And that's it, just the curly brackets. Then everything that goes into your JSON file will go between those two curly brackets. If anything is outside of them it will not work. – JΛYDΞV Jun 30 '21 at 01:36
  • Is there any other way to contact you if you are comfortable because here it is hard to share media files? – Darkstar Dream Jun 30 '21 at 05:18
  • You can contact me through my email, or gmail. I need to be able to see what your doing, and what the results are. Like it would be nice to see a picture of your entire editor, with your settings.json file open so I can see how your formatting your Color-token/Color Properties. https://GitHub.com/W3Dojo & W3Dojo@Gmail.com. We can open up a private room here on SO too, I believe. – JΛYDΞV Jun 30 '21 at 08:00
  • Thanks for sharing your contact information, I have sent an email you can check that out, Also I would recommend deleting the above comment for your privacy. – Darkstar Dream Jun 30 '21 at 14:24
  • Everything above is on my stackoverflow account – JΛYDΞV Jun 30 '21 at 14:55
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/234378/discussion-between-darkstar-dream-and-jaydev). – Darkstar Dream Jun 30 '21 at 16:14
0

ctrl+shift+p =>preferences:color theme==> select Dark+(default dark)

  • Hey there. Welcome to the stackoverflow! thank you for responding and answering to questions. please add some explanation to your code to be more helpful. Thank you – El.Hum Nov 05 '22 at 05:41