配置 vscode

· · 科技·工程

配置 vscode

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

下载 vscode

打开 下载vscode点击 downlowd。

安装 vscode 。

配置编辑器

打开 vscode ,选中插件。

添加插件:

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

打开 code runner 设置页面,勾选以下选项:

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

打开 code runner 的 settings.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 )

搜索 编辑系统环境变量。

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

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

重启 vscode。

运行程序

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

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

在下面的终端里输入输出。