跳到正文

科技·工程

配置 vscode

Gary0504约 11 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 11 分钟

版本

  1. v1当前

配置 vscode

总所周知,配置 VS code 是一个 oier 必备的技能。

下载 vscode

打开 下载vscode点击 downlowd。 7a9abca311baddeb648a292a68410345.png

安装 vscode 。

be8e1afff83b33e4061588810513bf5f.png

配置编辑器

打开 vscode ,选中插件。

添加插件:

C/C++
C/C++ Extension Pack
Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code
powershell
Code Runner

8c69379ef689af27ddc721b502bdb419.png 69515ca81787ee201c9780ce0aafce80.png 8fe65ef91ba133adc8d6f1d89c06db8f.png b741de5b0d5a28e4abc282a46476df65.png 打开 code runner 设置页面,勾选以下选项:

代码
vscode://settings/code-runner.runInTerminal
vscode://settings/code-runner.saveFileBeforeRun

45808ee97776aa53b6167027467579c8.png 786c4c6a7952e0f277a0525abd4b5417.png 1dd819c53970a777d8c2f185a49a2d18.png

打开 code runner 的 settings.json ,把文件替换文件内容并保存。

JSON
{
    "code-runner.runInTerminal": true,
    "code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ -std=c++14 -O2 -lm \"-Wl,--stack=0x1000000\" \"$fileName\" -o \"$fileNameWithoutExt\" && \"$fileNameWithoutExt\"",
        "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "php": "php",
        "python": "python -u",
        "perl": "perl",
        "perl6": "perl6",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
        "racket": "racket",
        "scheme": "csi -script",
        "ahk": "autohotkey",
        "autoit": "autoit3",
        "dart": "dart",
        "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        "haskell": "runhaskell",
        "nim": "nim compile --verbosity:0 --hints:off --run",
        "lisp": "sbcl --script",
        "kit": "kitc --run",
        "v": "v run",
        "sass": "sass --style expanded",
        "scss": "scss --style expanded",
        "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
        "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "sml": "cd $dir && sml $fileName"
    },
    "files.autoSave": "afterDelay",
    "files.defaultLanguage": "cpp",
    "terminal.integrated.defaultProfile.windows": "Command Prompt",
    "code-runner.languageIdToFileExtensionMap": {

        "bat": ".bat",
        "powershell": ".ps1",
        "typescript": ".ts"
    }
}

配置编译器

打开编译器的 bin 文件夹,复制路径,如(C:\Program Files (x86)\Dev-Cpp\MinGW64 ) 5f43e3929a00b67fd226e4bf5f2773da.png

搜索 编辑系统环境变量。

a51e3b180f679ffdb5dbd61388d0637e.png

将编译器的路径复制到 PATH 。

b92afba969e71b627c3f198b86a439ef.png

打开 cmd 输入 g++ -v,发现可以看见编译器信息。 4c6ea617b5f3b70251be37eb156f17a9.png

重启 vscode。

运行程序

新建一个 .cpp 的文件,输入代码。 点击右上角的小三角

注意!!是只有小三角的那一个,如果不是,点击 Run Code 。

在下面的终端里输入输出。 710d5b9331f83ca6266a86b900ec528b.png

原文