有没有办法在Visual Studio代码中使用斜体显示注释?

Ama*_*ani 17 visual-studio-code vscode-settings

我正在使用Visual Studio Code 1.11.2.我需要能够在任何语言文件中看到斜体的注释,或者至少是JavaScript,Python,C,C++.是否存在一般性设置,或者目前我是否可以通过编程方式实现这一目标?

Jas*_*son 31

谢谢你指出我正确的方向维克多.我想删除某个主题的斜体注释,并将其放入我的设置文件(Visual Studio Code 1.16.0)中.

"editor.tokenColorCustomizations": {
  "textMateRules": [
    {
      "scope": "comment",
      "settings": {
        "fontStyle": "normal"
      }
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

在你的情况,阿曼尼,更换normalitalic

编辑:似乎有些事情可能会有所改变.

如果规则无法应用,您可以使用Visual Studio Code(≥v1.9)TextMate Scope Inspector Widget轻松找出所需的范围选择器.

要访问它,请按,然后ctrl/cmd + shift + p查找Developer: Inspect TM Scopes

我目前已将以下内容应用于我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",
      }
    },
  ]
},
Run Code Online (Sandbox Code Playgroud)


Vic*_*tes 7

是的,有办法实现这一目标.

此答案适用于Microsoft Windows [版本10.0.14393],Visual Studio Code 1.14.2

如果您使用Extension MarketPlace中已安装的主题,则其文件位于 C:\Users\<YourUsername>\.vscode\extensions\

假设您正在使用Kal.theme-glacier.主题文件是这样的:

C:\Users\<YourUsername>\.vscode\extensions\Kal.theme-glacier-0.0.1\themes\glacier.tmTheme

在任何文本编辑器中编辑文件(建议使用Notepad ++)
编辑主题文件时不应运行Visual Studio代码,或者您可能需要重新启动VS-Code.

找到密钥名称Comment并更改FontStyleitalic.最后一段代码应如下所示:

<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>
Run Code Online (Sandbox Code Playgroud)

如果您使用的是默认主题(未从Extension MarketPlace安装),则位置在此处:

C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\theme-<name>.

假设您正在使用Light +(默认光照)主题.

您首先要查看的文件是
C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\theme-defaults\themes\light_plus.json

你会发现这里没有Comment键,但你会注意到"include": "./light_vs.json"这是你要编辑的实际文件.
最终块C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\theme-defaults\themes\light_vs.json应该如下所示:

{
    "scope": "comment",
    "settings": {
        "foreground": "#009000",
        "fontStyle": "italic"
    }
},
Run Code Online (Sandbox Code Playgroud)


hrv*_*j3e 6

更完整的答案发布在 Visual Studio Code GitHub 问题跟踪器上: 禁用斜体选项功能请求 #32579(主题)

例如:

punctuation.definition.comment禁用创建注释的字符上的斜体(例如://等)。

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": [
                "comment",
                "punctuation.definition.comment",
                "variable.language"
            ],
            "settings": {
                "fontStyle": ""
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)