vscode 编辑器配置c/c++

匿名 (未验证) 提交于 2019-12-03 00:08:02

 

launch.json 文件配置

 

{

 

    "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            // "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "program": "${workspaceFolder}\\build\\${fileBasenameNoExtension}.exe",  // 配置生成EXE文件路径,将EXE文件保存到单独的build文件夹

 

            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\ProgramFile\\mingw64\\bin\\gdb.exe",     // mingw64 安装位置
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc.exe build active file"
        }
    ]
}

 

tasks.json 文件配置
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++.exe build active file",
            "command": "D:\\ProgramFile\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                // "${fileDirname}\\${fileBasenameNoExtension}.exe"
                "${workspaceFolder}\\build\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "D:\\ProgramFile\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}




vscode 
settings.json文件   用于设置run code 快捷方式
该文件不在.vscode目录下 一般位于c盘 用户文件目录下 如 C:\Users\Administrator\AppData\Roaming\Code\User\settings.json   

 

```
{
    "code-runner.saveAllFilesBeforeRun": true,
    "code-runner.runInTerminal": true,
    "explorer.confirmDelete": false,
    "code-runner.executorMap": {
        "javascript": "node",
        "python": "python",
        "perl": "perl",
        "go": "go run",
        "c": "cd $dir && gcc $fileName -o $workspaceRoot/build/$fileNameWithoutExt && $workspaceRoot/build/$fileNameWithoutExt",   // c 编译
        "cpp": "cd $dir && g++ $fileName -o $workspaceRoot/build/$fileNameWithoutExt && $workspaceRoot/build/$fileNameWithoutExt", // c++ 编译
    },
    "workbench.iconTheme": "material-icon-theme",
    "files.autoGuessEncoding": true,
    "window.openFoldersInNewWindow": "on",
    "python.autoComplete.addBrackets": true,
    "workbench.colorTheme": "Visual Studio Light",
    // "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    // "terminal.integrated.shellArgs.windows": [" chcp 65001 >nul"],

 

}
```

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!