跳到正文

个人记录

VScode 快速配置

ywcw约 3 分钟
原文
文章信息与版本

文章信息

发布
2026年1月10日
收录
2026年11月13日
更新
2026年11月17日
篇幅
约 3 分钟
获赞
1

版本

  1. v1当前

本教程只针对OI。

  1. 安装 VSCODE。

  2. 下载 MinGW:Winlibs、MinGW-w64 - for 32 and 64 bit Windows Files ,并将 .\bin 添加到系统环境变量。

    对于 Linux

    对于 NOI Linux 2.0 一般默认内置了 G++ 9.3.0。

    可以输入 g++ --version 查询,若安装则会返回:

    代码
    g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
    Copyright (C) 2019 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    否则,请执行:

    Bash
    sudo apt update # 更新,可注释
    sudo apt install build-essential # 下载 gcc、g++
    sudo apt install gdb # 下载 gdb
  3. 安装插件

    代码
    C/C++
    Code Runner
    vscode-pdf
    Material Icon Theme
    ...
  4. 安装好后,新建一个文件:Hello.cpp,点击右上角按钮运行,或 Ctrl+Alt+N。

    C++
    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        cout << "Hello world!" << endl;
        return 0;
    }
  5. 更改一些设置 找到 Code Runner 的设置,进入。

    勾选:

    Code-runner: Run In Terminal

    • Whether to run code in Integrated Terminal.

    同时打开 Code-runner: Executor Map 找到: "cpp":... 替换为

    For Windows:

    JSON
    "cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt.exe\" && & \".\\$fileNameWithoutExt.exe\"",

    For Linux:

    JSON
    "cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt\" -O2 -std=c++14 -static && \"./$fileNameWithoutExt\"",```。
原文