VsCode仿Dev-c++

· · 个人记录

Ctrl+, -> 文本编辑器 -> 字体 -> 在 settings.json 中编辑,把东西复制进去,再选择浅色模式。

{
  "editor.semanticHighlighting.enabled": false,
  "C_Cpp.enhancedColorization": "Disabled",

  "editor.bracketPairColorization.enabled": true,
  "workbench.colorCustomizations": {
    "editorBracketHighlight.foreground1": "#FF0000",
    "editorBracketHighlight.foreground2": "#FF0000",
    "editorBracketHighlight.foreground3": "#FF0000",
    "editorBracketHighlight.foreground4": "#FF0000",
    "editorBracketHighlight.foreground5": "#FF0000",
    "editorBracketHighlight.foreground6": "#FF0000",
    "editorBracketHighlight.unexpectedBracket.foreground": "#FF0000",
    "editor.lineHighlightBackground": "#D0FFFF",
    "editor.lineHighlightBorder": "#00000000"
  },

  "editor.tokenColorCustomizations": {
    "variables": "#000000",
    "classes": "#000000",
    "types": "#000000",
    "functions": "#000000",

    "textMateRules": [
      // 1. 注释 -> #0078D7 浅蓝色斜体
      {
        "scope": ["comment", "punctuation.definition.comment"],
        "settings": { "foreground": "#0078D7", "fontStyle": "italic" }
      },

      // 2. 预处理指令及整行 -> 全绿色 (让宏名 ll、替换体 long long 等全变绿)
      {
        "scope": [
          "keyword.control.directive",
          "punctuation.definition.directive",
          "meta.preprocessor",
          "meta.preprocessor.include",
          "keyword.control.directive.include",
          "string.quoted.other.lt-gt.include",
          "string.quoted.double.include",
          "punctuation.definition.string.begin",
          "punctuation.definition.string.end",

          // ★ 新增以下内容,彻底锁死 #define 后面的内容 ★
          "entity.name.function.preprocessor",      // 宏名 ll
          "meta.preprocessor entity.name",          // 宏名兜底
          "meta.preprocessor keyword",              // 宏里的关键字
          "meta.preprocessor storage",              // 宏里的修饰符
          "meta.preprocessor storage.type",         // 宏里的类型 long long
          "meta.preprocessor string",               // 宏里的字符串
          "meta.preprocessor constant.numeric",     // 宏里的数字
          "meta.preprocessor variable"              // 宏里的变量
        ],
        "settings": { "foreground": "#008000", "fontStyle": "" }
      },

      // 3. 关键字 -> 黑色加粗 (using, namespace, int, for 等)
      {
        "scope": [
          "keyword",
          "keyword.control",
          "keyword.other",
          "keyword.other.using.directive.cpp",
          "keyword.other.namespace",
          "storage",
          "storage.type",
          "storage.modifier"
        ],
        "settings": { "foreground": "#000000", "fontStyle": "bold" }
      },

      // 4. 数字 -> 紫色不加粗
      {
        "scope": ["constant.numeric", "constant.numeric.integer", "constant.numeric.float"],
        "settings": { "foreground": "#800080", "fontStyle": "" }
      },

      // 5. 字符常量 (单引号 ' ') -> 黑色不加粗
      {
        "scope": ["constant.character", "string.quoted.single.char"],
        "settings": { "foreground": "#000000", "fontStyle": "" }
      },

      // 6. 字符串 (双引号 "") -> 蓝色加粗
      {
        "scope": ["string", "string.quoted.double"],
        "settings": { "foreground": "#0000FF", "fontStyle": "bold" }
      },

      // 7. 符号与括号 -> 红色加粗
      {
        "scope": [
          "punctuation.section.parens",
          "punctuation.section.block",
          "punctuation.section.brackets",
          "keyword.operator",
          "punctuation.separator",
          "punctuation.terminator"
        ],
        "settings": { "foreground": "#FF0000", "fontStyle": "bold" }
      },

      // 8. 全量普通标识符兜底 -> 黑色不加粗 (ios, cin, main, s 等)
      {
        "scope": [
          "variable",
          "variable.other",
          "variable.parameter",
          "variable.other.object",
          "variable.other.property",
          "variable.other.class",
          "variable.language",
          "entity.name",
          "entity.name.type",
          "entity.name.type.class",
          "entity.name.type.struct",
          "entity.name.class",
          "entity.name.struct",
          "entity.name.namespace",
          "entity.name.function",
          "entity.name.function.definition",
          "entity.name.scope-resolution",
          "support.type",
          "support.class",
          "support.function",
          "support.variable",
          "support.constant",
          "meta.function-call",
          "meta.object-literal.key",
          "storage.type.class",
          "storage.type.struct"
        ],
        "settings": { "foreground": "#000000", "fontStyle": "" }
      }
    ]
  },
  "workbench.colorTheme": "Light 2026",
  "editor.fontLigatures": false
}