微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何让我的 vscode 字体像 sublime 一样倾斜?

如何解决如何让我的 vscode 字体像 sublime 一样倾斜?

我在 VScode 和 sublime 中使用 相同的字体(Consolas)。但在同一个地方看起来不一样:

enter image description here

enter image description here

这是我的 sublime 设置:

{
    "auto_complete_selector": "source,text","color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme","font_face": "Consolas","font_size": 12,"ignored_packages":
    [
    ],"theme": "Default.sublime-theme"
}

这是我的 vscode 设置:

    "materialTheme.accent": "Blue","editor.fontFamily": "Consolas,'Courier New',monospace","editor.fontWeight": 520,"editor.codeLensFontSize": 11,"editor.fontSize": 15,"editor.formatOnType": true,"debug.console.fontFamily": "Cascadia Mono","python.showStartPage": false,"workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb","filenamePattern": "*.ipynb"
        }
    ],"explorer.confirmDelete": false,"todo-tree.tree.showScanModeButton": true,"editor.fontligatures": true,"editor.tokenColorCustomizations": {
       "comments": "#7ea9eb"
    

我的问题是:如何让我的 vscode 字体像 sublime 一样倾斜?

解决方法

根据 VS Code documentation,您可以使用用户设置中的 editor.tokenColorCustomizations 规则自定义主题颜色:

  1. 打开您的 settings.json 并首先添加以下规则(将 YOUR THEME NAME HERE 替换为您的颜色主题名称):

    "editor.tokenColorCustomizations": {
       "[YOUR THEME NAME HERE]": {
          "textMateRules": []
       }
    }
    
  2. 打开您选择的 Python 文件。然后,使用 Ctrl+Shift+P 打开命令面板并运行“Developer: Inspect Editor Tokens and Scopes”

  3. 单击您希望将其设为斜体的关键字。例如,我们单击 class 关键字以查看其 TextMate 范围。复制突出显示的第一个 TextMate 范围 ID:

    Textmate scope example

  4. 回到你的settings.json。在 textMateRules 数组中,插入一个新对象,其 scope 属性是您刚刚复制的 TextMate 范围 ID。

    "editor.tokenColorCustomizations": {
       "[YOUR THEME NAME HERE]": {
          "textMateRules": [
            {
              "scope": "storage.type.class.python","settings": {
                "fontStyle": "italic"
              }
            }
          ]
       }
    }
    
  5. 保存您的 settings.json,您应该会看到 class 键盘以斜体显示

    Class being italic

注意

您可以在 textMateRules 数组中附加更多对象,使更多关键字的字体变为斜体。例如:

"editor.tokenColorCustomizations": {
  "[YOUR THEME NAME HERE]": {
    "textMateRules": [
      {
        "scope": "variable.parameter.function.language.special.self.python","settings": {
          "fontStyle": "italic"
        }
      },{
        "scope": "storage.type.class.python","settings": {
          "fontStyle": "italic"
        }
      }
    ]
  }
},

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。