C/C++VSCode环境配置

软件下载地址

VSCode:https://code.visualstudio.com/
MinGW:https://sourceforge.net/projects/mingw/files/latest/download
Dev-C++:https://sourceforge.net/projects/orwelldevcpp/

launsh.json

点击查看代码
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "preLaunchTask": "build", //任务命令
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files (x86)\\Dev-Cpp\\MinGW64\\bin\\gdb.exe", // 编译器目录
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }]
}

tasks.json

点击查看代码
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "build",
            "command": "C:\\Program Files (x86)\\Dev-Cpp\\MinGW64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

settings.json

点击查看代码
{
    // "files.defaultLanguage": "cpp", // 默认语言
    "editor.mouseWheelZoom": true, // 鼠标放大缩小
    "editor.fontSize": 18, // 设置字体大小
    "editor.tabSize": 4, // 设置缩进空格宽度
    "editor.lineNumbers": "on", // 显示行号
    "editor.formatOnSave": true, // Ctrl+S 保存的同時格式化
    "C_Cpp.clang_format_style": "{ BasedOnStyle: Chromium, IndentWidth: 4}", // 左大括号不换行
    // "workbench.colorTheme": "Visual Studio Light", // 指定用在工作台中的颜色主题,白
    "workbench.colorTheme": "Visual Studio Dark - C++", // 指定用在工作台中的颜色主题,黑
    // 终端颜色配置
    "workbench.colorCustomizations": {
        // 可以将鼠标放到下面的色号上根据自己的偏好进行选择
        "terminal.foreground": "#04d331",
        "terminal.background": "#000000"
    },
    "terminal.integrated.fontSize": 18, // 字体大小设置
    "workbench.editor.enablePreview": true, //控制打开的编辑器是否显示为预览编辑器
}

cpp.json

点击查看代码
{
    "cpp": {
        "prefix": "cpp",
        "body": [
            "#include<bits/stdc++.h>",
            "#define int long long",
            "using namespace std;",
            "typedef long long ll;",
            "const int N=1e6+10, inf=0x3f3f3f3f,inf2=1e18;\n",
            "signed main(){",
            "    freopen(\"1.in\", \"r\", stdin);",
            "\n\n\n",
            "    return 0;",
            "}"
        ]
    }
}
posted @ 2025-08-03 13:03  HelloHeBin  阅读(16)  评论(0)    收藏  举报