在Visual Studio代码中修改编辑器文本颜色? [英] Modify editor text color in visual studio code?
问题描述
也许有人可以在Visual Studio Code中帮助我解决一些小问题,这使我发疯...;-/ ...
- 我知道如何安装和切换不同的颜色主题(例如
dark-plus等)。 - 我发现了如何修改(在设置中)。 json):
editor.tokenColorCustomizations:{
[暗加语法]:{{
comments:#649664}
但是我所有的谷歌搜索都没有显示最基本的修改是可行的:我如何仅更改标准编辑器字体颜色?
任何想法如何做到这一点我想将大多数深色主题的明亮字体颜色稍微加深一点,以减少对比度/眼睛疲劳...。
我试图修改相应的文件(例如dark-plus-syntax-color-theme.json),但仅使用默认字体颜色在文件中找不到任何内容。
[注意:我认为这有点荒谬,我发现-在谷歌搜索一个小时的同时-各种方式进行自定义...但不是最简单的调整。]
让我们具体说一下,并尝试更改常规标签。使用 Dark +标记时,C ++源文件中标识符等的文本颜色。主题。在我的设置中,这些标识符的颜色为#D4D4D4, (浅灰色,如RRGGBB)。出于演示目的,我将其更改为#080 (中绿色,如RGB)。
首先打开C ++源文件。打开命令面板(Ctrl + Shift + P),然后运行开发人员:检查TM范围。
编辑2020-08-04:从VSCode 1.47.2(可能更早)开始,该命令现在称为 开发人员:检查编辑器令牌和范围。
调用该命令后,将光标移至标识符。例如:
在这种情况下,我们注意到它说 ;没有主题选择器。这意味着主题的 tokenColors
属性未设置此颜色,而是主题的普通 colors
属性,特别是 editor.foreground
颜色。可以通过设置 workbench.colorCustomizations
来覆盖
好的,但是操作员仍保留其原始颜色。使用开发人员:检查编辑器令牌和范围。再次:
这次,而不是否主题选择器。
keyword.operator { foreground:#d4d4d4 }
这是主题的 tokenColors
属性的规则,我们需要在 settings.json
中使用 textMateRules
覆盖它:
editor.tokenColorCustomizations:{
textMateRules:[
{
scope:[
keyword.operator ,
],
设置:{
foreground:#080,
},
},
],
},
现在,操作员也是绿色的。
< a href = https://i.stack.imgur.com/mSWKf.png rel = nofollow noreferrer>
根据需要重复该过程,直到所有颜色都被覆盖。
如果你想赚更多的钱对于复杂的更改(例如仅更改某些操作员颜色),我建议阅读 TextMate范围选择器手册。这就是范围标签堆栈会很有用。但是请注意,VSCode并没有完全实现 那里描述的内容(尽管很接近),并且没有实现。
设置
属性的文档不充分,但是基本上您可以设置前景
颜色和仅fontStyle
。 fontStyle
可以是粗体
,斜体$ c $的任何空格分隔的组合c>和
下划线
。不幸的是,您无法设置背景颜色。
Maybe someone can help me with a little problem in Visual Studio Code, which drives me crazy... ;-/ ...
- I know how to install and switch different color themes (like "dark-plus" etc.).
- I found out how to modify things like (in settings.json):
editor.tokenColorCustomizations": { "[dark-plus-syntax]": { "comments": "#649664" }
But all my googling didn't reveal the most basic modification thinkable: How do I only change the standard editor font color?
Any idea how to do this easily? I want to darken the bright font color of most dark color themes just a little bit to reduce the contrast/eye strain....
I tried to modify the corresponding file (e.g. dark-plus-syntax-color-theme.json), but found nothing in it for just the default font color.
[NB: I think it's almost a bit absurd, that I found out - while googling for an hour - all kinds of ways how to customize... but not this most simple tweak.]
Let's be specific, and try to change the "normal" text color for identifiers, etc., in a C++ source file when using the "Dark+" theme. In my setup, these identifiers have the color "#D4D4D4" (light gray, as RRGGBB). For demonstration purposes I'll change it to "#080" (medium green, as RGB).
Start by opening a C++ source file. Open the Command Palette (Ctrl+Shift+P) and run the "Developer: Inspect TM Scopes" command.
Edit 2020-08-04: As of VSCode 1.47.2 (and perhaps a bit earlier), the command is now called "Developer: Inspect Editor Tokens and Scopes".
After invoking that command, move the cursor to an identifier. For example:
In this case, we notice it says "No theme selector." That means the tokenColors
attribute of the theme is not setting this color, rather it is the ordinary colors
attribute of the theme, specifically the editor.foreground
color. This can be overridden as in Sean's answer by setting workbench.colorCustomizations
in settings.json
:
"workbench.colorCustomizations": {
"editor.foreground": "#080"
},
Save settings.json
and return to the C++ source file. It now looks like this:
Ok, that's progress, but the operators still have their original color. Use "Developer: Inspect Editor Tokens and Scopes" again:
This time, instead of "No theme selector.", we see:
keyword.operator { "foreground": "#d4d4d4" }
That is a rule from the theme's tokenColors
attribute and we need to override that using textMateRules
in settings.json
:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"keyword.operator",
],
"settings": {
"foreground": "#080",
},
},
],
},
Now the operators are also green:
Repeat the procedure as needed until all colors are overridden.
If you want to make more complex changes (like changing only certain operator colors), I recommend reading the TextMate Scope Selectors manual. That's where the "scope label stack" would be useful. But be aware that VSCode does not implement exactly what is described there (although it is close), and what it does implement is not documented.
The capabilities of the settings
attribute are not well documented, but basically you can set the foreground
color and the fontStyle
, only. The fontStyle
can be any space-separated combination of bold
, italic
, and underline
. You cannot set the background color, unfortunately.
这篇关于在Visual Studio代码中修改编辑器文本颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!