【发布时间】:2017-12-24 23:43:45
【问题描述】:
我浏览了https://code.visualstudio.com/docs/getstarted/theme-color-reference,但似乎找不到更改评论颜色的设置。
我目前正在使用 Atom One 深色主题,只是想将颜色调亮一点,以便更好地阅读。
【问题讨论】:
标签: visual-studio-code vscode-settings
我浏览了https://code.visualstudio.com/docs/getstarted/theme-color-reference,但似乎找不到更改评论颜色的设置。
我目前正在使用 Atom One 深色主题,只是想将颜色调亮一点,以便更好地阅读。
【问题讨论】:
标签: visual-studio-code vscode-settings
从1.15 (July 2017)你可以从settings.json更改它 Ctrl+,
"editor.tokenColorCustomizations": {
"comments": "#d4922f"
},
从1.20 (January 2018)你也可以为每个主题分别做:
"editor.tokenColorCustomizations": {
"[Atom One Dark]": {
"comments": "#d4922f"
}
},
找到合适的范围:
开发者:检查 TM Scopes editor.action.inspectTMScopes
选择器优先级:
https://code.visualstudio.com/blogs/2017/02/08/syntax-highlighting-optimizations#_textmate-themes
好的,更多示例(js):
"editor.tokenColorCustomizations": {
"textMateRules": [{
"scope": "INSERT_SCOPE_HERE",
"settings": {
"foreground": "#ff0000"
}
}]
}
comment
punctuation.definition.comment
comment.block.documentation
storage.type.class.jsdoc
entity.name.type.instance.jsdoc
variable.other.jsdoc
【讨论】:
/** 和 */ 在设置评论颜色后保持不变。中间部分正在改变颜色。
扩展答案和@Johnny Derp 的评论。您可以使用以下方法更改字体颜色和样式:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "comment",
"settings": {
"fontStyle": "italic",
"foreground": "#C69650",
}
}
]
},
background不能这样改,只能改颜色和样式。截至 2018 年 6 月。
还回答了几个 cmets 关于更改 cmets puntuation(如 //)颜色的问题 - 现在必须使用自己的 textmate 规则单独着色,可能会在 10 月份进行更改以解决该问题2019 年发布 - 目前这是一个未解决的问题,但已添加到 2019 年 10 月的里程碑中。见https://github.com/microsoft/vscode/milestone/102
【讨论】:
在 VS 代码中:1.56.2
添加到settings.json:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"comment",
"comment.block.documentation",
"comment.block.documentation.js",
"comment.line.double-slash.js",
"storage.type.class.jsdoc",
"entity.name.type.instance.jsdoc",
"variable.other.jsdoc",
"punctuation.definition.comment",
"punctuation.definition.comment.begin.documentation",
"punctuation.definition.comment.end.documentation"
],
"settings": {
"fontStyle": "italic",
"foreground": "#287a1d"
}
}
]
}
如果仍然缺少stoff:CTRL+SHIFT+P => Developer: Inspect Editor Tokens and Scopes 将鼠标悬停在未正确着色的部分上并将它们添加到"scope"。
你来了。 :)
【讨论】:
目前无法在设置中自定义令牌颜色:
最突出的编辑器颜色是基于的标记颜色 关于语言语法安装。这些颜色由 颜色主题,(目前)不能在设置中自定义。
来源:https://code.visualstudio.com/docs/getstarted/theme-color-reference
我确实注意到,如果您进入主题文件夹,例如: C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\theme-monokai 并编辑 monokai-color-theme.json 文件,查找带有 "name": "Comment" 的行并更改它可以工作的 "foreground" 颜色。只需确保重新启动程序即可。
【讨论】:
就像马克说的,但是在"comment"之后添加"scope":
“标点符号.definition.comment”
给标点上色,
例如(
//in javescript |/* */in cs |<!-- -->in html)。
"scope": ["comment", "punctuation.definition.comment"]
【讨论】:
为 Doc、Block 和 Line cmets 设置不同的颜色:
"editor.tokenColorCustomizations": {
"[Cobalt2]": {
"textMateRules": [
{
"scope": [
"comment.block",
"punctuation.definition.comment.end",
"punctuation.definition.comment.begin"
],
"settings": {
"foreground": "#85b3f8",
"fontStyle": "bold"
}
},
{
"scope": [
"comment.block.documentation",
"punctuation.definition.comment.begin.documentation",
"punctuation.definition.comment.end.documentation"
],
"settings": {
"foreground": "#6bddb7",
"fontStyle": "bold"
}
},{
"scope":["comment.line", "punctuation.definition.comment"],
"settings": {
"foreground": "#FF0000",
"fontStyle": "bold"
}
}
]
}
}
用 C++ 测试。
【讨论】:
更改 VS Code 注释颜色
文件 --> 首选项 --> 设置
选择“工作区设置”选项卡以仅针对该项目进行更改
选择“用户设置”选项卡为所有项目更改它
搜索“settings.json”并寻找“在 settings.json 中编辑”的选项
在大括号内的某处为 cmets 插入此颜色设置:
“editor.tokenColorCustomizations”:{
"cmets": "#ff4"
}
它可能会抱怨您正在覆盖当前的颜色主题,请忽略它。
如果已经有一个“editor.tokenColorCustomizations”部分,那么只需添加该行来指定注释颜色。
【讨论】:
在评论评论主题时,我发现 VS Code 的“更好的评论”扩展非常有用。您可以为您的 cmets 赋予各种颜色,从而根据重要性等对您的 cmets 进行分类。
默认 cmets 颜色也可以更改。
https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments
示例:
可以在用户设置或工作区设置中配置此扩展。
【讨论】: