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