I'm using Visual Studio Code version 1.11.2. I need to be able to see italicized comments in any language file, or at least JavaScript, Python, C, C++. Is there a general setting for that or is there a programmatic way I can achieve that at the moment?
问题:
回答1:
Thanks for pointing me in the right direction Victor. I wanted to get rid of italicized comments for a certain theme and putting this in my settings file (Visual Studio Code 1.16.0) did the trick:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "comment",
"settings": {
"fontStyle": "normal"
}
}
]
}
In your case, Amani, replace normal
with italic
Edit: It seems some things mights have changed a bit.
If the rules fail to apply, you can easily figure out which scope selector(s) you will need by using Visual Studio Code's (≥ v1.9) TextMate Scope Inspector Widget.
To access it, press ctrl/cmd + shift + p
and look for Developer: Inspect TM Scopes
I have currently applied the following to my settings.json
:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Comment",
"scope": [
"comment",
"comment.block",
"comment.block.documentation",
"comment.line",
"comment.line.double-slash",
"punctuation.definition.comment",
],
"settings": {
"fontStyle": "",
// "fontStyle": "italic",
// "fontStyle": "italic underline",
// "fontStyle": "italic bold underline",
}
},
]
},
回答2:
Yes, there are ways to accomplish this.
This answer applies to Microsoft Windows [Version 10.0.14393], Visual Studio Code 1.14.2
If you are using an installed theme from the Extension MarketPlace, their files are located at C:\Users\<YourUsername>\.vscode\extensions\
Let's say you are using Kal.theme-glacier. The theme file is this:
C:\Users\<YourUsername>\.vscode\extensions\Kal.theme-glacier-0.0.1\themes\glacier.tmTheme
Edit the file in any text editor (Notepad++ recommended)
Visual Studio Code should not be running while editing theme files or you may need to restart VS-Code.
Find the key name Comment
and change the FontStyle
to italic
. Final Block of code should look like this:
<dict>
<key>name</key>
<string>Comment</string>
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#515c68</string>
</dict>
</dict>
If you are using a default theme (not installed from the Extension MarketPlace), then the location is here:
C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\theme-<name>
.
Let's say you are using Light+ (default light) theme.
The file you want to look at first is
C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\theme-defaults\themes\light_plus.json
You will find there's no Comment
key in here but you'll notice "include": "./light_vs.json"
Then this is actual file you want to edit.
Final block in C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\theme-defaults\themes\light_vs.json
should look like this:
{
"scope": "comment",
"settings": {
"foreground": "#009000",
"fontStyle": "italic"
}
},
回答3:
A more complete answer is posted on VS Code Github Issue tracker https://github.com/Microsoft/vscode/issues/32579#issuecomment-341502559
For example:
punctuation.definition.comment
to disable italic on the characters that creating comments (like: // and others).
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"comment",
"punctuation.definition.comment",
"variable.language"
],
"settings": {
"fontStyle": ""
}
}
]
}
回答4:
you can check out this link:
https://code.visualstudio.com/blogs/2017/02/08/syntax-highlighting-optimizations
It mentions nothing about comments being an eligible scope for theming VS CODE.