VSCode自定义配色方案的实现

说明

本文更新于2019-02-18,使用VSCode 1.14.1,操作系统为Windows。

配置文件

“文件-首选项-颜色主题”即可显示所有可用的颜色主题,上下选择后Enter即可。也可通过Ctrl+Shift+P输入color theme回车后调出“首选项:颜色主题”面板。

记VSCode的安装目录为$RELEASE,默认的颜色主题配置文件都位于$RELEASE/resources/app/extensions目录中。以theme-开头的目录即为颜色主题配置(事实上,其中有些是文件图标主题)。除若干主题会共用一个目录外(theme-defaults),大多数主题都是一个主题一个目录。

每个颜色主题配置目录包含以下文件:themes目录、OSSREADME.jsonpackage.jsonthemes目录下通常使用.json设置具体的配色方案;OSSREADME.json描述版权等相关信息,可以忽略;package.json令VSCode读取后能区分不同的配色方案。

下面新增一个灰色调颜色主题。在$RELEASE/resources/app/extensions目录下新增如下目录结构。如果你不关心配置文件相关参数的解释,可无需细读后面内容,只需将相应的配置文本复制至配置文件中即可,但需注意文件均为UTF-8编码。

$RELEASE/resources/app/extensions/
 \_ theme-gv-gray/
   \_ themes/
   |  \_ gv-gray-color-theme.json
   |_ package.json

预览图

package.json

package.json文件内容如下:

{
	"name": "theme-gv-gray",
	"version": "0.1.0",
	"publisher": "GV",
	"engines": { "vscode": "*" },
	"contributes": {
		"themes": [
			{
				"label": "gv-gray",
				"uiTheme": "vs",
				"path": "./themes/gv-gray-color-theme.json"
			}
		]
	}
}
参数名 作用
name 主题ID,必需在VSCode中全局唯一,即所有主题的package.json中该值均不能重复
contributes -> themes -> label 主题名,“文件-首选项-颜色主题”的列表中显示该值
contributes -> themes -> uiTheme VSCode整体的UI主题,vs为浅色主题
contributes -> themes -> path 定义配色方案的文件名,如为相对路径则相对于此文件

因配置文件内容太长放至文末,以下说明对照配置文件内容阅读更易理解。

VSCode使用其以下两个节点:

参数名 作用
colors VSCode各个UI组件的颜色
tokenColors 语法高亮颜色

colors节点的内容直接通过键值对参数描述,以下列举几个参数的作用:

图示 参数名 作用
2 activityBar.background 活动栏背景色
1 activityBar.foreground 活动栏前景色(例如用于图标)
12 editor.background 编辑器背景颜色
13 editor.foreground 编辑器默认前景色
editor.findMatchBackground 当前搜索匹配项的颜色
editor.findMatchHighlightBackground 其他搜索匹配项的颜色
15 editor.lineHighlightBackground 光标所在行高亮文本的背景颜色
editor.selectionBackground 编辑器所选内容的颜色
editor.selectionHighlightBackground 与所选内容具有相同内容的区域颜色
editor.rangeHighlightBackground 突出显示范围的背景颜色,例如 "Quick Open" 和“查找”功能
16 editorBracketMatch.background 匹配括号的背景色
14 editorCursor.foreground 编辑器光标颜色
11 editorGutter.background 编辑器导航线的背景色,导航线包括边缘符号和行号
10 editorLineNumber.foreground 编辑器行号颜色
5 sideBar.background 侧边栏背景色
4 sideBar.foreground 侧边栏前景色
3 sideBarSectionHeader.background 侧边栏节标题的背景颜色
17 statusBar.background 标准状态栏背景色
17 statusBar.noFolderBackground 没有打开文件夹时状态栏的背景色
17 statusBar.debuggingBackground 调试程序时状态栏的背景色
9 tab.activeBackground 活动选项卡的背景色
8 tab.activeForeground 活动组中活动选项卡的前景色
7 tab.inactiveBackground 非活动选项卡的背景色
6 tab.inactiveForeground 活动组中非活动选项卡的前景色

tokenColors

tokenColors使用一个对象数组描述各语法高亮颜色。每个对象有如下结构:

{
	"name": "Comment",
	"scope": [
		"comment",
		"punctuation.definition.comment"
	],
	"settings": {
		"background": "#ffffff",
		"fontStyle": "italic",
		"foreground": "#000000"
	}
}
参数名 作用
name 规则描述,一段容易理解的描述性文字
scope 作用域,指定使用那些VSCode内部对象,其含义参看Scope Naming
setting -> background 背景色,可选
setting -> fontStyle 字体,可选,为bold、italic、underline
setting -> foreground 前景色,可选

以下列举文末的配置文件中几个name所指定的参数的作用:

参数名 作用
Character 字符
Class 类名
Comment 注释
Function 函数名
Keyword 关键字
Number 数值
Operator 运算符
Parameter 函数参数
Punctuation 标点符号
String 字符串
Type 内置类型
Variable 变量名

文件内容

{
	"name": "gv-gray",
	"colors": {
		"activityBar.background": "#e0e0e0",
		"activityBar.foreground": "#000000",
		"editor.background": "#c8c8c8",
		"editor.foreground": "#000000",
		"editor.findMatchBackground": "#ffff00",
		"editor.findMatchHighlightBackground": "#ffff00",
		"editor.lineHighlightBackground": "#c0c0c0",
		"editor.selectionBackground": "#b0b0b0",
		"editor.selectionHighlightBackground": "#dfdfdf",
		"editor.rangeHighlightBackground": "#b0b0b0",
		"editorBracketMatch.background": "#b0b0b0",
		"editorCursor.foreground": "#333333",
		"editorGutter.background": "#d3d3d3",
		"editorLineNumber.foreground": "#777777",
		"sideBar.background": "#f5f5f5",
		"sideBar.foreground": "#000000",
		"sideBarSectionHeader.background": "#e0e0e0",
		"statusBar.background": "#444444",
		"statusBar.noFolderBackground": "#444444",
		"statusBar.debuggingBackground": "#444444",
		"tab.activeBackground": "#afafaf",
		"tab.activeForeground": "#000000",
		"tab.inactiveBackground": "#e0e0e0",
		"tab.inactiveForeground": "#000000",
		// Other colors.
		"activityBarBadge.background": "#705697",
		"button.background": "#705697",
		"dropdown.background": "#F5F5F5",
		"editorGroup.dropBackground": "#C9D0D988",
		"editorWhitespace.foreground": "#AAAAAA",
		"focusBorder": "#A6B39B",
		"inputOption.activeBorder": "#adafb7",
		"inputValidation.infoBorder": "#4ec1e5",
		"inputValidation.infoBackground": "#f2fcff",
		"inputValidation.warningBackground": "#fffee2",
		"inputValidation.warningBorder": "#ffe055",
		"inputValidation.errorBackground": "#ffeaea",
		"inputValidation.errorBorder": "#f1897f",
		"list.activeSelectionForeground": "#6c6c6c",
		"list.focusBackground": "#CADEB9",
		"list.activeSelectionBackground": "#c4d9b1",
		"list.inactiveSelectionBackground": "#d3dbcd",
		"list.highlightForeground": "#9769dc",
		"notification.background": "#442e66",
		"panel.background": "#F5F5F5",
		"peekViewEditor.matchHighlightBackground": "#C2DFE3",
		"peekViewTitle.background": "#F2F8FC",
		"peekViewEditor.background": "#F2F8FC",
		"peekViewResult.background": "#F2F8FC",
		"peekView.border": "#705697",
		"peekViewResult.matchHighlightBackground": "#93C6D6",
		"pickerGroup.foreground": "#A6B39B",
		"pickerGroup.border": "#749351"
	},
	"tokenColors": [
		{
			"settings": {
				"background": "#ffffff",
				"foreground": "#000000"
			}
		},
		{
			"name": "Character",
			"scope": [
				"constant",
				"constant.character"
			],
			"settings": {
				"foreground": "#008000"
			}
		},
		{
			"name": "Class",
			"scope": [
				"entity.name.type",
				"entity.other.inherited-class",
				"support.class"
			],
			"settings": {
				"foreground": "#000080"
			}
		},
		{
			"name": "Comment",
			"scope": [
				"comment",
				"punctuation.definition.comment"
			],
			"settings": {
				"fontStyle": "italic",
				"foreground": "#0066ff"
			}
		},
		{
			"name": "Function",
			"scope": [
				"entity.name.function",
				"support.function"
			],
			"settings": {
				"foreground": "#000000"
			}
		},
		{
			"name": "Keyword",
			"scope": [
				"keyword",
				"storage"
			],
			"settings": {
				"fontStyle": "bold",
				"foreground": "#000080"
			}
		},
		{
			"name": "Number",
			"scope": [
				"constant.numeric"
			],
			"settings": {
				"foreground": "#0044bb"
			}
		},
		{
			"name": "Operator",
			"scope": "keyword.operator",
			"settings": {
				"foreground": "#000000"
			}
		},
		{
			"name": "Parameter",
			"scope": "variable.parameter",
			"settings": {
				"fontStyle": "underline"
			}
		},
		{
			"name": "Punctuation",
			"scope": "punctuation",
			"settings": {
				"foreground": "#000000"
			}
		},
		{
			"name": "String",
			"scope": "string",
			"settings": {
				"foreground": "#008000"
			}
		},
		{
			"name": "Type",
			"scope": [
				"storage.type",
				"support.type"
			],
			"settings": {
				"fontStyle": "",
				"foreground": "#000080"
			}
		},
		{
			"name": "Variable",
			"scope": [
				"support.variable",
				"variable"
			],
			"settings": {
				"foreground": "#000000"
			}
		},
		// Other token colors.
		{
			"name": "Comments: Preprocessor",
			"scope": "comment.block.preprocessor",
			"settings": {
				"fontStyle": "",
				"foreground": "#AAAAAA"
			}
		},
		{
			"name": "Comments: Documentation",
			"scope": [
				"comment.documentation",
				"comment.block.documentation"
			],
			"settings": {
				"foreground": "#448C27"
			}
		},
		{
			"name": "Invalid - Deprecated",
			"scope": "invalid.deprecated",
			"settings": {
				"background": "#96000014"
			}
		},
		{
			"name": "Invalid - Illegal",
			"scope": "invalid.illegal",
			"settings": {
				"background": "#96000014",
				"foreground": "#660000"
			}
		},
		{
			"name": "Language Constants",
			"scope": [
				"constant.language",
				"support.constant",
				"variable.language"
			],
			"settings": {
				"foreground": "#AB6526"
			}
		},
		{
			"name": "Exceptions",
			"scope": "entity.name.exception",
			"settings": {
				"foreground": "#660000"
			}
		},
		{
			"name": "Sections",
			"scope": "entity.name.section",
			"settings": {
				"fontStyle": "bold"
			}
		},
		{
			"name": "Strings: Escape Sequences",
			"scope": "constant.character.escape",
			"settings": {
				"foreground": "#777777"
			}
		},
		{
			"name": "Strings: Regular Expressions",
			"scope": "string.regexp",
			"settings": {
				"foreground": "#4B83CD"
			}
		},
		{
			"name": "Strings: Symbols",
			"scope": "constant.other.symbol",
			"settings": {
				"foreground": "#AB6526"
			}
		},
		{
			"name": "Embedded Source",
			"scope": [
				"string source",
				"text source"
			],
			"settings": {
				"background": "#EAEBE6"
			}
		},
		{
			"name": "HTML: Doctype Declaration",
			"scope": [
				"meta.tag.sgml.doctype",
				"meta.tag.sgml.doctype string",
				"meta.tag.sgml.doctype entity.name.tag",
				"meta.tag.sgml punctuation.definition.tag.html"
			],
			"settings": {
				"foreground": "#AAAAAA"
			}
		},
		{
			"name": "HTML: Tags",
			"scope": [
				"meta.tag",
				"punctuation.definition.tag.html",
				"punctuation.definition.tag.begin.html",
				"punctuation.definition.tag.end.html"
			],
			"settings": {
				"foreground": "#91B3E0"
			}
		},
		{
			"name": "HTML: Tag Names",
			"scope": "entity.name.tag",
			"settings": {
				"foreground": "#4B83CD"
			}
		},
		{
			"name": "HTML: Attribute Names",
			"scope": [
				"meta.tag entity.other.attribute-name",
				"entity.other.attribute-name.html"
			],
			"settings": {
				"fontStyle": "italic",
				"foreground": "#91B3E0"
			}
		},
		{
			"name": "HTML: Entities",
			"scope": [
				"constant.character.entity",
				"punctuation.definition.entity"
			],
			"settings": {
				"foreground": "#AB6526"
			}
		},
		{
			"name": "CSS: Selectors",
			"scope": [
				"meta.selector",
				"meta.selector entity",
				"meta.selector entity punctuation",
				"entity.name.tag.css"
			],
			"settings": {
				"foreground": "#7A3E9D"
			}
		},
		{
			"name": "CSS: Property Names",
			"scope": [
				"meta.property-name",
				"support.type.property-name"
			],
			"settings": {
				"foreground": "#AB6526"
			}
		},
		{
			"name": "CSS: Property Values",
			"scope": [
				"meta.property-value",
				"meta.property-value constant.other",
				"support.constant.property-value"
			],
			"settings": {
				"foreground": "#448C27"
			}
		},
		{
			"name": "CSS: Important Keyword",
			"scope": "keyword.other.important",
			"settings": {
				"fontStyle": "bold"
			}
		},
		{
			"name": "Markup: Changed",
			"scope": "markup.changed",
			"settings": {
				"background": "#FFFFDD",
				"foreground": "#000000"
			}
		},
		{
			"name": "Markup: Deletion",
			"scope": "markup.deleted",
			"settings": {
				"background": "#FFDDDD",
				"foreground": "#000000"
			}
		},
		{
			"name": "Markup: Emphasis",
			"scope": "markup.italic",
			"settings": {
				"fontStyle": "italic"
			}
		},
		{
			"name": "Markup: Error",
			"scope": "markup.error",
			"settings": {
				"background": "#96000014",
				"foreground": "#660000"
			}
		},
		{
			"name": "Markup: Insertion",
			"scope": "markup.inserted",
			"settings": {
				"background": "#DDFFDD",
				"foreground": "#000000"
			}
		},
		{
			"name": "Markup: Link",
			"scope": "meta.link",
			"settings": {
				"foreground": "#4B83CD"
			}
		},
		{
			"name": "Markup: Output",
			"scope": [
				"markup.output",
				"markup.raw"
			],
			"settings": {
				"foreground": "#777777"
			}
		},
		{
			"name": "Markup: Prompt",
			"scope": "markup.prompt",
			"settings": {
				"foreground": "#777777"
			}
		},
		{
			"name": "Markup: Heading",
			"scope": "markup.heading",
			"settings": {
				"foreground": "#AA3731"
			}
		},
		{
			"name": "Markup: Strong",
			"scope": "markup.bold",
			"settings": {
				"fontStyle": "bold"
			}
		},
		{
			"name": "Markup: Traceback",
			"scope": "markup.traceback",
			"settings": {
				"foreground": "#660000"
			}
		},
		{
			"name": "Markup: Underline",
			"scope": "markup.underline",
			"settings": {
				"fontStyle": "underline"
			}
		},
		{
			"name": "Markup Quote",
			"scope": "markup.quote",
			"settings": {
				"foreground": "#7A3E9D"
			}
		},
		{
			"name": "Markup Lists",
			"scope": "markup.list",
			"settings": {
				"foreground": "#4B83CD"
			}
		},
		{
			"name": "Markup Styling",
			"scope": [
				"markup.bold",
				"markup.italic"
			],
			"settings": {
				"foreground": "#448C27"
			}
		},
		{
			"name": "Markup Inline",
			"scope": "markup.inline.raw",
			"settings": {
				"fontStyle": "",
				"foreground": "#AB6526"
			}
		},
		{
			"name": "Extra: Diff Range",
			"scope": [
				"meta.diff.range",
				"meta.diff.index",
				"meta.separator"
			],
			"settings": {
				"background": "#DDDDFF",
				"foreground": "#434343"
			}
		},
		{
			"name": "Extra: Diff From",
			"scope": "meta.diff.header.from-file",
			"settings": {
				"background": "#FFDDDD",
				"foreground": "#434343"
			}
		},
		{
			"name": "Extra: Diff To",
			"scope": "meta.diff.header.to-file",
			"settings": {
				"background": "#DDFFDD",
				"foreground": "#434343"
			}
		}
	]
}

到此这篇关于VSCode自定义配色方案的实现的文章就介绍到这了,更多相关VSCode自定义配色 内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • VSCode下配置python调试运行环境的方法

    VSCode配置python调试环境 很久之前的一个东东,翻出来看看 VSCode配置python调试环境 * 1.下载python解释器 * 2.在VSCode市场中安装Python插件 * 4.在用户设置里加两条 * 5.接下来是正式的调试了 1080 两个数的平方和 Input Output Input示例 Output示例 1.下载python解释器 python 3.6.3 for windows 安装到系统某个路径例如C:\Python36 最好添加到Path,也可以不加 2.在VS

  • VSCode配置Git的方法步骤随记

    vscode中对git进行了集成,很多操作只需点击就能操作,无需写一些git指令. 不过这就需要你对vscode进行配置.下面我会讲到git的配置与免密码上传github. 一.安装Git管理工具,可上官网安装,安装路径https://git-scm.com/,安装路径默认C:\Program Files\Git,可自行修改,这里我是安装在D:\Program Files\Git. 二.安装完Git之后,如图配置好环境变量path路径的信息,一般会自动配置成功,配置完成后电脑就可以使用Git了.

  • 浅谈用VSCode写python的正确姿势

    最近在学习python,之前一直用notepad++作为编辑器,偶然发现了VScode便被它的颜值吸引.用过之后发现它启动快速,插件丰富,下载安装后几乎不用怎么配置就可以直接使用,而且还支持markdown.当然,最主要的还是好看:p 效果图: VScode下载地址 安装python插件 打开VScode,Ctrl+p 输入 "ext install python",搜索时间可能会比较长 选择下载量最高的那个插件点击安装(根据网络情况,安装时间不确定,我当初装了挺久,我这边已经下载好了

  • 在vscode中使用Git的教程

    vscode简介 VSCode是微软推出的一款轻量编辑器,采取了和VS相同的UI界面,搭配合适的插件可以优化前端开发的体验. 布局:左侧是用于展示所要编辑的所有文件和文件夹的文件管理器,依次是资源管理器,搜索,GIT,调试,插件,右侧是打开文件的编辑区域,最多可同时打开三个编辑区域到侧边.在初次使用时如果本地没有安装git会提示先安装git,然后重启vscode. 用了git最方便的就是比如在公司写了很多代码后回到家打开vscode只需要点击一下pull就能全部同步过来.是不是很方便....毕竟

  • VScode编写第一个Python程序HelloWorld步骤

    一.软件下载与安装 VScode下载地址:https://code.visualstudio.com/ VScode的github项目地址(本文用不到):https://github.com/microsoft/vscode Python下载地址:https://www.python.org/downloads/ 笔者用的是win版的VScode1.0和32位Python2.7,安装Python时注意将Python添加到系统环境变量 二.VScode项目结构简介 VScode使用的是文件夹命名的

  • 详解vscode中vue代码颜色插件

    vue提示插件[Vscode] 编者寄语:vscode的确是前端开发中很好的工具,安装颜色插件,从视觉上是美的享受.曾经的我遇到了vscode代码全是灰色,黑色的困惑,后来整理找到方法,整理这篇,以下高亮插件,建议大家都安装了. 在VSCode Marketplace 搜素Vue 出现关于语法高亮的插件有 vue,vue-beautify,vue-color,VueHelper,vertur等等.比较了下载数量可以了解到,vetur 是目前比较好的语法高亮插件,我们来安装一下吧. vscode提

  • VSCode配置react开发环境的步骤

    vscode 默认配置对于 react 的 JSX 语法不友好,体现在使用自动格式化或者粘贴后默认缩进错误,尽管可以通过改变 language mode 缓解错误,但更改 language mode 后的格式化依然不够理想. 通过搭配使用 ESLint和 Prettier插件可以实现在 vscode 中完美支持 JSX 语法. 编辑器安装插件 在 vscode 中需要安装下面插件: ESLint Prettier 项目中的配置 配置ESLint 基础配置 项目中安装 babel-eslint ,

  • VSCode下好用的Python插件及配置

    MS Python插件. 这是微软官方的Python插件,已经自带很多功能.下面是插件功能描述,其中部分内容我做了翻译. a)        Linting (Prospector, Pylint, pycodestyle, Flake8, pylama, pydocstyle, mypy with config files and plugins)静态代码扫描(可以理解为代码语法和格式错误提示,支持多种linter) b)       Intellisense (autocompletion

  • VsCode新建VueJs项目的详细步骤

    本文介绍了VsCode新建VueJs,分享给大家,具体如下: 使用vue-cli快速构建项目 ( vue-cli 是vue.js的脚手架,用于自动生成vue.js模板工程的. 安装vue-cli之前,需要先安装了vue和webpack ) · node -v //(版本低引起:bash: npm: command not found) · npm -v //以上帮助检查是否安装 node npm · 输入vue,//测试vue是否安装成功 · 输入vue list //看vue中有哪些子类 np

  • 在vscode中统一vue编码风格的方法

    vetur 很多人知道,但在 vscode 下没办法格式化 .vue 里的 html, js 很是头疼,代码风格无法统一. 所以不少人直接拆分开,然后在 .vue 中引入,虽然方法很好,但这有违 .vue 单文件组件的初衷. 本文详细介绍 vscode 下使用 vetur + prettier + eslint 来统一 vue 编码风格. vetur 插件 vetur 经过多个版本迭代,算是目前 vscode 下最好用的 vue 插件了,甚至支持 ts, webpack alias 等特性. 但

  • 如何使用VSCode愉快的写Python于调试配置步骤

    在学习Python的过程中,一直没有找到比较趁手的第三方编辑器,用的最多的还是Python自带的编辑器.由于本人用惯了宇宙第一IDE(Visual Studio),所以当Visual Studio Code出现时,心情有点小激动呢.从我的使用经验出发,可以说VSCode用来写Python真的是再合适不过了,你将体验到丝滑的编程体验和无限扩展的可能.而且,如果你的项目是包含多种语言的,比如Web开发,你不必再开多个编辑器和其他工具,因为这一切都可以在VSCode里完成了. vscode下载地址:/

  • VsCode插件整理(小结)

    1.VsCode官方插件地址: https://marketplace.visualstudio.com/vscode http://code.visualstudio.com/docs 官网下载地址:http://code.visualstudio.com/ 2.使用方法,可以在官网中搜索需要的插件或者在VsCode的""扩展""中搜索需要的插件 添加方法使用Ctrl+P, 输入 ext install xxxx ,搜索要安装的插件,点击安装按钮即可 3.常用插件

随机推荐