跳到正文

个人记录

vscode 配置

#SUSPENDED#约 26 分钟
原文

这是 2026年9月21日 存档的第 2 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年9月16日
收录
2026年9月18日
更新
2026年11月21日
篇幅
约 26 分钟
获赞
1

版本

  1. v4当前
  2. v3
  3. v2
  4. v1

基础设置

打开设置(Ctrl + ,),搜索并修改以下几项:

  • 自动保存:搜索 Auto Save,选择 afterDelay,避免因忘记保存导致代码丢失。
  • Ctrl+滚轮缩放:搜索 Ctrl,勾选 Editor: Mouse Wheel Zoom,像 Dev-C++ 一样用 Ctrl + 滚轮调整字号。
  • Tab 缩进:若习惯用 Tab,需搜索 Detect Indentation 和 Insert Spaces,全部取消勾选,否则 Tab 会被自动转为空格。
  • 界面语言:NOI Linux 的 VS Code 默认为英文。可通过命令面板(Ctrl+Shift+P)输入 Configure Display Language,选择 zh-cn 并重启,但考场可能无法下载语言包,建议提前适应英文界面。

编译与运行配置

方式一:手动终端编译

打开内置终端(Ctrl + `),使用以下命令编译运行:

Bash
g++ 文件名.cpp -o 文件名 -std=c++14 -O2 -Wall 
./文件名

方式二:配置 tasks.json 实现一键编译

如需在 VS Code 内按快捷键编译,可创建 .vscode/tasks.json 文件。

JSON
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "编译 C++(评测版)",
      "type": "shell",
      "command": "g++",
      "args": [
        "-std=c++14",
        "-O2",
        "-Wall",
        "-Wextra",
        "-g",
        "-Wl,--stack=1024000000",
        "${file}",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}.exe"
      ],
      "options": {
        "cwd": "${fileDirname}",
        "shell": {
          "executable": "C:\\Windows\\System32\\cmd.exe",
          "args": ["/d", "/c"]
        }
      },
      "problemMatcher": ["$gcc"],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "presentation": {
        "reveal": "silent",
        "panel": "shared",
        "clear": true
      }
    },
    {
      "label": "编译 C++(调试版)",
      "type": "shell",
      "command": "g++",
      "args": [
        "-std=c++14",
        "-O0",
        "-g",
        "-Wall",
        "-Wextra",
        "-Wl,--stack=1024000000",
        "${file}",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}.exe"
      ],
      "options": {
        "cwd": "${fileDirname}",
        "shell": {
          "executable": "C:\\Windows\\System32\\cmd.exe",
          "args": ["/d", "/c"]
        }
      },
      "problemMatcher": ["$gcc"],
      "group": "build",
      "presentation": {
        "reveal": "silent",
        "panel": "shared",
        "clear": true
      }
    },
    {
      "label": "运行 C++",
      "type": "shell",
      "command": "${fileDirname}/${fileBasenameNoExtension}.exe",
      "options": {
        "cwd": "${fileDirname}"
      },
      "dependsOn": ["编译 C++(评测版)"],
      "dependsOrder": "sequence",
      "group": {
        "kind": "test",
        "isDefault": true
      },
      "presentation": {
        "reveal": "always",
        "panel": "shared",
        "clear": true
      },
      "problemMatcher": []
    }
  ]
}

配置后,按 Ctrl+Shift+B 即可编译当前文件。

颜色配置

代码
{
    "vs64.showWelcome": false,
    "code-runner.runInTerminal": true,
    "editor.fontSize": 20,
    "cmake.showOptionsMovedNotification": false,
    "code-runner.executorMapByGlob": {
        "pom.xml": "cd $dir && mvn clean package"
    },
    "workbench.colorTheme": "Dark Modern",
    "files.autoSave": "afterDelay",
    "editor.mouseWheelZoom": true,
    "editor.detectIndentation": false,
	"editor.insertSpaces": false,
	"terminal.integrated.enableMultiLinePasteWarning": "never"
}
代码
{
  "workbench.colorCustomizations": {
    "editorCursor.foreground": "#ffffff",
    "editorCursor.background": "#ffffff",
    "editor.lineHighlightBackground": "#30cfff1e",
    "editor.lineHighlightBorder": "#30cfff1e",

    "editor.findMatchBackground": "#ffeb3b7a",
    "editor.findMatchBorder": "#ffeb3b7a",
    "editor.findMatchHighlightBackground": "#B3E5FC44",
    "editor.findMatchHighlightBorder": "#03A9F4",

    "editorBracketHighlight.foreground1": "#fffb00cb",
    "editorBracketHighlight.foreground2": "#7bff00d0",
    "editorBracketHighlight.foreground3": "#00aeffcb",
    "editorBracketHighlight.foreground4": "#8c00ffc2",
    "editorBracketHighlight.foreground5": "#ff00aac6",
    "editorBracketHighlight.foreground6": "#ff8800d0",
    "editorBracketHighlight.unexpectedBracket.foreground": "#FF0000",
    "editorBracketMatch.background": "#5c5c5c",
    "editorBracketMatch.border": "#5c5c5c",

    "terminalCursor.foreground": "#ffffff",
    "terminalCursor.background": "#ffffff"
  }
}
代码
{
    "vs64.showWelcome": false,
    "code-runner.runInTerminal": true,
    "editor.fontSize": 20,
    "editor.lineHeight": 30,
    "cmake.showOptionsMovedNotification": false,
    "code-runner.executorMapByGlob": {
        "pom.xml": "cd $dir && mvn clean package"
    },
    "workbench.colorTheme": "Dark Modern",
    "files.autoSave": "afterDelay",
    "editor.mouseWheelZoom": true,
    "editor.detectIndentation": false,
    "editor.insertSpaces": false,
    "terminal.integrated.enableMultiLinePasteWarning": "never",

    "workbench.colorCustomizations": {
        "activityBar.background": "#040A12",
        "activityBar.foreground": "#26C6DA",
        "activityBar.inactiveForeground": "#2A4A5A",
        "activityBarBadge.background": "#0288D1",
        "activityBarBadge.foreground": "#040A12",

        "sideBar.background": "#040A12",
        "sideBar.foreground": "#A9C2D9",
        "sideBarTitle.foreground": "#26C6DA",
        "sideBarSectionHeader.background": "#07101E",
        "sideBarSectionHeader.foreground": "#4DB6AC",

        "editor.background": "#040A12",
        "editor.foreground": "#A9C2D9",
        "editorLineNumber.foreground": "#1E3A4A",
        "editorLineNumber.activeForeground": "#26C6DA",
        "editorCursor.foreground": "#4DB6AC",
        "editor.selectionBackground": "#0288D144",
        "editor.inactiveSelectionBackground": "#0288D122",
        "editor.lineHighlightBackground": "#07101E",
        "editor.findMatchBackground": "#26C6DA66",
        "editor.findMatchHighlightBackground": "#0288D144",
        "editorWhitespace.foreground": "#0F2233",
        "editorIndentGuide.background1": "#0F2233",
        "editorIndentGuide.activeBackground1": "#26C6DA",
        "editorBracketMatch.background": "#0288D133",
        "editorBracketMatch.border": "#0288D1",
        "editorGutter.background": "#040A12",
        "editorGroupHeader.tabsBackground": "#040A12",
        "editorGroup.border": "#0F2233",
        "editorOverviewRuler.border": "#0F2233",
        "editorError.foreground": "#E57399",
        "editorWarning.foreground": "#D4B85C",
        "editorInfo.foreground": "#26C6DA",
        "editorHint.foreground": "#4DB6AC",

        "statusBar.background": "#05293F",
        "statusBar.foreground": "#A9C2D9",
        "statusBar.noFolderBackground": "#040A12",
        "statusBar.debuggingBackground": "#0288D1",

        "titleBar.activeBackground": "#040A12",
        "titleBar.activeForeground": "#26C6DA",
        "titleBar.inactiveBackground": "#040A12",
        "titleBar.inactiveForeground": "#2A4A5A",

        "tab.activeBackground": "#040A12",
        "tab.activeForeground": "#4DB6AC",
        "tab.inactiveBackground": "#040A12",
        "tab.inactiveForeground": "#456A7A",
        "tab.border": "#07101E",
        "tab.activeBorderTop": "#26C6DA",

        "panel.background": "#040A12",
        "panel.border": "#0F2233",
        "panelTitle.activeForeground": "#26C6DA",
        "panelTitle.inactiveForeground": "#456A7A",

        "terminal.background": "#040A12",
        "terminal.foreground": "#A9C2D9",
        "terminal.ansiBlack": "#040A12",
        "terminal.ansiRed": "#E57399",
        "terminal.ansiGreen": "#26A69A",
        "terminal.ansiYellow": "#4DB6AC",
        "terminal.ansiBlue": "#0288D1",
        "terminal.ansiMagenta": "#29B6F6",
        "terminal.ansiCyan": "#26C6DA",
        "terminal.ansiWhite": "#A9C2D9",
        "terminal.ansiBrightBlack": "#1E3A4A",
        "terminal.ansiBrightRed": "#F48FB1",
        "terminal.ansiBrightGreen": "#4DB6AC",
        "terminal.ansiBrightYellow": "#80CBC4",
        "terminal.ansiBrightBlue": "#42A5F5",
        "terminal.ansiBrightMagenta": "#81D4FA",
        "terminal.ansiBrightCyan": "#80DEEA",
        "terminal.ansiBrightWhite": "#E0F7FA",

        "button.background": "#0288D1",
        "button.foreground": "#040A12",
        "button.hoverBackground": "#26C6DA",

        "input.background": "#07101E",
        "input.foreground": "#A9C2D9",
        "input.border": "#0288D1",
        "inputOption.activeBorder": "#26C6DA",

        "dropdown.background": "#07101E",
        "dropdown.foreground": "#A9C2D9",
        "dropdown.border": "#0288D1",

        "list.activeSelectionBackground": "#0288D133",
        "list.activeSelectionForeground": "#A9C2D9",
        "list.hoverBackground": "#07101E",
        "list.highlightForeground": "#26C6DA",

        "scrollbarSlider.background": "#26C6DA33",
        "scrollbarSlider.hoverBackground": "#26C6DA55",
        "scrollbarSlider.activeBackground": "#26C6DA88",

        "badge.background": "#0288D1",
        "badge.foreground": "#040A12",
        "progressBar.background": "#26C6DA",

        "editorWidget.background": "#07101E",
        "editorWidget.border": "#0288D1",
        "editorSuggestWidget.background": "#07101E",
        "editorSuggestWidget.border": "#0288D1",
        "editorSuggestWidget.selectedBackground": "#0288D133",
        "editorHoverWidget.background": "#07101E",
        "editorHoverWidget.border": "#0288D1",

        "peekView.border": "#26C6DA",
        "peekViewEditor.background": "#040A12",
        "peekViewResult.background": "#040A12",

        "gitDecoration.addedResourceForeground": "#26A69A",
        "gitDecoration.modifiedResourceForeground": "#29B6F6",
        "gitDecoration.deletedResourceForeground": "#E57399",
        "gitDecoration.untrackedResourceForeground": "#26C6DA",
        "gitDecoration.ignoredResourceForeground": "#2A4A5A"
    },

    "editor.tokenColorCustomizations": {
        "comments": "#3B5A6B",
        "strings": "#4DB6AC",
        "keywords": "#26C6DA",
        "numbers": "#80CBC4",
        "types": "#42A5F5",
        "functions": "#26A69A",
        "variables": "#A9C2D9",

        "textMateRules": [
            {
                "scope": ["comment", "punctuation.definition.comment"],
                "settings": {
                    "foreground": "#3B5A6B",
                    "fontStyle": "italic"
                }
            },
            {
                "scope": ["string", "punctuation.definition.string"],
                "settings": {
                    "foreground": "#4DB6AC"
                }
            },
            {
                "scope": ["keyword", "storage.type", "storage.modifier"],
                "settings": {
                    "foreground": "#26C6DA",
                    "fontStyle": "bold"
                }
            },
            {
                "scope": ["entity.name.function", "support.function"],
                "settings": {
                    "foreground": "#26A69A"
                }
            },
            {
                "scope": ["variable", "variable.parameter"],
                "settings": {
                    "foreground": "#A9C2D9"
                }
            },
            {
                "scope": ["constant.numeric", "constant.language"],
                "settings": {
                    "foreground": "#80CBC4"
                }
            },
            {
                "scope": ["entity.name.type", "support.type", "support.class", "storage.type"],
                "settings": {
                    "foreground": "#42A5F5"
                }
            },
            {
                "scope": ["constant.other", "variable.language"],
                "settings": {
                    "foreground": "#0288D1"
                }
            },
            {
                "scope": ["keyword.operator"],
                "settings": {
                    "foreground": "#456A7A"
                }
            },
            {
                "scope": ["punctuation", "meta.brace"],
                "settings": {
                    "foreground": "#456A7A"
                }
            },
            {
                "scope": ["markup.heading"],
                "settings": {
                    "foreground": "#26C6DA",
                    "fontStyle": "bold"
                }
            },
            {
                "scope": ["markup.bold"],
                "settings": {
                    "fontStyle": "bold"
                }
            },
            {
                "scope": ["markup.italic"],
                "settings": {
                    "fontStyle": "italic"
                }
            }
        ]
    },
    
    "background.enabled": true,
    "background.editor": {
        "images": [
            "file:///home/你的用户名/Pictures/bg.jpg"
        ],
        "useFront": false,
        "style": {
            "background-position": "center center",
            "background-size": "cover",
            "opacity": 0.08,
            "background-repeat": "no-repeat",
            "filter": "brightness(0.6) contrast(0.8)"
        },
        "interval": 0,
        "random": false
    }
}