vscode&C/C++配置(新手)

插件

C/C++(必备)
C/C++ Compile Run
:类似code Runner
Chinese(simplified) Language
:中文官方插件
Todo Tree
:标记管理TODO的位置和文件

美化类:

Beautify
:代码美化
Material Theme
:主题,个人喜欢material darker high contrast,
(但是注释过浅,可在settings的json文件设置一下字符颜色)

 "editor.tokenColorCustomizations": {
        "comments": {
            // 设置字体样式 加粗 下划线 斜体等
            "fontStyle": "",
            // 设置字体颜色
            "foreground": "#3887b1"//可以通过前面小方框的颜色直接从拾色器上选
        }, // 注释
        
        //将comments修改成其他,类比换其他部分颜色
        // "keywords": "#0a0", // 关键字颜色
        // "variables": "#f00", // 变量名颜色
        // "strings": "#e2d75dbd", // 字符串颜色
        // "functions": "#5b99fcc9", // 函数名颜色
        // "numbers": "#AE81FF" // 数字颜色

Bracket Pair Colorizer 2
:括号对应

.vsode文件

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/software/mingw64/mingw64/bin/gdb.exe",
            "preLaunchTask": "g++",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
        },
    ]
}

launch.json需要根据自己安装的mingw位置/其他C++IDE(比如codeblocks、devc++)的bin的文件夹位置修改,注意斜杠的方向要做修改

tasks.json

{
    "version": "2.0.0",
    "command": "g++",
    "args": [
        "-g",
        "${file}",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}.exe"
    ],
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": [
            "relative",
            "${workspaceRoot}"
        ],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    },
    "group": {
        "kind": "build",
        "isDefault": true
    }
}

其他注意

1.文件名必须符合命名要求,中文,其他字符都会导致找不到文件位置
2.使用vscode打开整个文件夹(包含.vscode)

评论

暂无评论