vscode 设置字体颜色

发布于:2025-03-09 ⋅ 阅读:(86) ⋅ 点赞:(0)

修改setting.json文件

{
    "remote.SSH.remotePlatform": {
        "ubuntu": "linux"
    },
    // "workbench.colorTheme": "One Dark Pro",
    // "editor.semanticTokenColorCustomizations": {
    // },
    "editor.semanticTokenColorCustomizations": {
        "enabled": true, // enable for all themes
        "rules": {
            "*.static": {
                "foreground": "#ff0000",
                "fontStyle": "bold"
            },
            "property": { //属性
                "foreground": "#22ff04",
                "fontStyle": "bold"
            },
            "macro": { //宏
                "foreground": "#234bfa",
                "fontStyle": "bold"
            },
            // "function": {   //函数
            //     "foreground": "#e4db5f",
            //     "fontStyle": "bold"
            // },
            "variable.global": { //全局变量
                "foreground": "#ff09ff",
                "fontStyle": "bold"
            },
            "variable.local": { //局部变量
                "foreground": "#71c3f3",
                // "fontStyle": "bold"
            },
        }
    },
    // 自定义的颜色
    "editor.tokenColorCustomizations": {
        // "[C++].variable.other.readwrite": "#88d8b0", // 类实例化的对象颜色 能用吗
        "comments": "#1d965a", // 注释
        "keywords": "#da10f5", // 关键字
        "variables": "#d8aeff", // 变量名 函数的参数名 
        // "strings": "#00f7ff", // 字符串
        "functions": "#d8e662", // 自定义及内置的函数名称 如:print
        // "numbers": "#00eeff", // 数字
        "types": "#ff8717", //类定义颜色
        "textMateRules": [
            {
                "scope": "keyword.control",// 为控制关键字 if、else、for、while、return 等
                "settings": {
                    "foreground": "#C586C0"
                }
            },
            {
                "scope": "keyword.operator", // 操作符 +、-、*、/、=、==、!= 等
                "settings": {
                    // "foreground": "#f07d3b"
                }
            },
            {
                "scope": "storage.modifier", // 修饰符 const、static、volatile、inline
                "settings": {
                    "foreground": "#3b47f7"
                }
            },
            {
                "scope": "entity.name.type.class", // 为类名(如 MyClass)设置颜色
                "settings": {
                    "foreground": "#fd9116"
                }
            },
            {
                "scope": "entity.name.type.interface", // 为接口名(如 MyInterface)设置颜色
                "settings": {
                    "foreground": "#ff0505"
                }
            },
            {
                "scope": "entity.name.namespace", // 为命名空间设置颜色
                "settings": {
                    "foreground": "#0cfab2"
                }
            },
            // {
            //     "scope": "entity.name.tag", // 为标签名
            //     "settings": {
            //         "foreground": "#d35c5c"
            //     }
            // }
        ]
    },
    "highlightwords.box": {
        "light": true, // 在亮色主题下不显示边框
        "dark": false // 在暗色主题下显示边框
    },
    // 选中高亮的颜色
    "workbench.colorCustomizations": {
        "editor.selectionBackground": "#406b6d"
    },
}