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

插件

C/C++(必備)
C/C++ Compile Run
:相似code Runner
Chinese(simplified) Language
:中文官方插件
Todo Tree
:標記管理TODO的位置和文件c++

美化類:

Beautify
:代碼美化
Material Theme
:主題,我的喜歡material darker high contrast,
(可是註釋過淺,可在settings的json文件設置一下字符顏色)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的文件夾位置修改,注意斜槓的方向要作修改ui

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)spa

相關文章
相關標籤/搜索