vscode 编辑器配置c/c++


 vscode 使用笔记

vscode 常用插件:

code runner :支持快捷执行

Visual Studio IntelliCode:智能代码提示

prettier-code formatter:代码格式化 ,win下快捷键为shift+alt+F

 

 

 

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",
  // 下面两行用于解决vscode 终端输出中文乱码的情况
    // "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",   
    // "terminal.integrated.shellArgs.windows": [" chcp 65001 >nul"],   
   
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "python.jediEnabled": false,
    "vetur.format.defaultFormatter.html": "prettier",
    "[html]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "terminal.integrated.rendererType": "dom",
    "files.autoSave": "afterDelay",
 
}
```

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM