更新时间:2023-01-27 12:10:20
Visual Studio Code 0.9.0 及更高版本
有关于如何添加自定义主题的官方文档:https://github.com/Microsoft/vscode-docs/blob/0.9.0/release-notes/latest.md
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
对于要添加的主题,您需要一个 .tmtheme
文件.您可以找到现有文件,例如在 GitHub 上,ColorSublime 或者您可以定义自己的主题文件(例如使用 https://github.com/aziz/tmTheme-Editor).
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).
找到 .tmtheme
文件后,您有两种方法可以基于它创建扩展.
After finding a .tmtheme
file you have two ways to create an extension based on it.
选项 1:使用 Yeoman 生成器
npm install -g yo
npm install -g generator-code
yo code
并选择New Color Theme
.tmTheme
文件、主题名称、ui 主题等)npm install -g yo
npm install -g generator-code
yo code
and select New Color Theme
.tmTheme
file, theme name, ui theme etc.)选项 2:自己创建目录
mytheme
.themes
并将 .tmTheme
文件放入其中在扩展文件夹的根目录下创建一个文件package.json
,内容如下
mytheme
.themes
and place the .tmTheme
file inside of itCreate 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"
}
]
}
}
最后将您的扩展添加到 Visual Studio Code
将扩展文件夹复制到扩展目录.这是:
Copy the extension folder to the extension directory. This is:
在 Windows 上 %USERPROFILE%\.vscode\extensions
在 Mac/Linux 上 $HOME/.vscode/extensions
重启VSCode,在File->中选择新的主题;首选项 ->颜色主题
Visual Studio 代码 0.8.0
可以在 Visual Studio Code 0.8.0 中添加新主题(于 2015 年 8 月 31 日发布给内部人员 [成为内部人员:https://www.instant.ly/s/Y5nt1/nav#p/186a0]).
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]).
安装 VSCode 0.8.0 或更高版本后,执行此操作以应用您自己的主题:
After installing VSCode 0.8.0 or higher do this to apply your own theme:
.tmTheme
文件或创建自己的文件(例如使用 https://github.com/aziz/tmTheme-Editor).tmTheme
文件复制到 %CODEFOLDER%/resources/app/plugins/vs.theme.starterkit/themes
在 %CODEFOLDER%/resources/app/plugins/vs.theme.starterkit/ticino.plugin.json
中注册 .tmTheme
文件,添加一个像这样的条目:
.tmTheme
file or create your own (for example with https://github.com/aziz/tmTheme-Editor).tmTheme
file to %CODEFOLDER%/resources/app/plugins/vs.theme.starterkit/themes
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
},
重启VSCode并在File->中选择新主题首选项 ->颜色主题