Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

color scheme - How to add theme in Visual Studio Code?

I recently downloaded the VS code editor which is really nice. but the only problem I find in it is the color theme, I am use to monokai color theme like in sublime text and I can't find a way to edit the color theme or download a color theme there are only 2 options:

  1. Dark Theme
  2. Light Theme

How can I add my own theme or duplicate existing one so I will be able to edit the color scheme as I want to?


I manage to change some of the colors in the following file but still I don`t know how to add completely new theme:

resources/app/client/vs/monaco/ui/workbench/native/native.main.css

Looks like color themes will be available soon and it will be a part of a plugin system

visual-studio-code/suggestions/7756227-theme

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Visual Studio Code 0.9.0 and later

There's an official documentation on how to add a custom theme: https://github.com/Microsoft/vscode-docs/blob/0.9.0/release-notes/latest.md

You need a .tmtheme file for the themeyou want to add. You can find existing files e.g. on GitHub, ColorSublime or you can define your own theme file (for example with https://github.com/aziz/tmTheme-Editor).

After finding a .tmtheme file you have two ways to create an extension based on it.

Option 1: Using a Yeoman generator

  • Install node.js (if you haven't already done)
  • Install yo (if you haven't already done) by executing npm install -g yo
  • Install the Yo generator for code: npm install -g generator-code
  • Run yo code and select New Color Theme
  • Follow the instructions (define the .tmTheme file, theme name, ui theme etc.)
  • The generator creates a directory for your extension with the name of the theme in your current working directory.

Option 2: Create the directory on your own

  • Create a directory with the name of your plugin (only lowercase letters). Let's say we call it mytheme.
  • Add a subfolder themes and place the .tmTheme file inside of it
  • Create a file package.json inside the root of the extension folder with content like this

    {        
        "name": "theme-mytheme",
        "version": "0.0.1",
        "engines": {
            "vscode": ">=0.9.0-pre.1"
        },
        "publisher": "me",
       "contributes": {
            "themes": [
                {
                    "label": "My Theme",
                    "uiTheme": "vs-dark", // use "vs" to select the light UI theme
                    "path": "./themes/mytheme.tmTheme"
                }
            ]
        }
    }
    

Finally add your extension to Visual Studio Code

Copy the extension folder to the extension directory. This is:

  • on Windows %USERPROFILE%.vscodeextensions

  • on Mac/Linux $HOME/.vscode/extensions

Restart VSCode and select the new theme in File -> Preferences -> Color Theme

Visual Studio Code 0.8.0

It's possible to add new themes in Visual Studio Code 0.8.0 (released for insiders on 2015-08-31 [become an insider: https://www.instant.ly/s/Y5nt1/nav#p/186a0]).

After installing VSCode 0.8.0 or higher do this to apply your own theme:

  1. Download a .tmTheme file or create your own (for example with https://github.com/aziz/tmTheme-Editor)
  2. Copy the .tmTheme file to %CODEFOLDER%/resources/app/plugins/vs.theme.starterkit/themes
  3. Register the .tmTheme file in %CODEFOLDER%/resources/app/plugins/vs.theme.starterkit/ticino.plugin.json by adding an entry for it like this:

    {
        "id": "vs-theme-mynewtheme", // internal ID
        "label": "MyNewTheme",       // displayed name for the theme
        "uiTheme": "vs-dark",        // general UI appeareance (
                                     // "vs" for light themes, 
                                     // "vs-dark" for dark themes)
        "path": "./themes/myNewTheme.tmTheme" // file path 
    },  
    
  4. Restart VSCode and select the new theme in File -> Preferences -> Color Theme


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...