$$ \newcommand{\seq}[2]{{#1}_{1},{#1}_{2},\cdots,{#1}_{#2}} \newcommand{\num}[1]{1,2,\cdots,#1} \newcommand{\stra}[2]{\begin{bmatrix}#1 \\ #2\end{bmatrix}} \newcommand{\strb}[2]{\begin{Bmatrix}#1 \\ #2\end{Bmatrix}} \newcommand{\dw}[1]{\underline{#1}} \newcommand{\up}[1]{\overline{#1}} $$

Windows & Ubuntu Vscode 配置c++环境

背景

被三岁神仙 \(\color{black}{\text{Q}}\color{red}{\text{Y}}\) 使用了rm -rf *(还好有备份)

安装

首先装一个叫做ubuntu make的东西:

sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
sudo apt-get update
sudo apt-get install ubuntu-make

然后用它

umake web visual-studio-code

中间会有一个询问,输入a+回车

卸载

umake web visual-studio-code --remove

配置中文环境

点一下左边菜单上从上往下第5个(一个方形),查找并安装Chinese (Simplified) Language Pack for Visual Studio Code插件,然后重启vscode

打开一个文件/文件夹

在首页点击打开文件打开文件夹

配置c++环境

安装以下插件:

点击左下角的设置图标,点击设置,进入设置页面,再点击右上角的大括号{},进入settings.json的文件,在里面输入:
linux

{
      // tab 大小为4个空格
  "editor.tabSize": 4,
  // 编辑器换行
  "editor.wordWrap": "off",
  //code runner
  "code-runner.executorMap": {
    "javascript": "node",
    "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt -Wall && $dir$fileNameWithoutExt", // C 编译命令
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -std=c++11 -Wall && $dir$fileNameWithoutExt", // C++ 编译命令
    "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",
    "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"
  },
  "code-runner.runInTerminal": true, // 让 code runner 在终端中运行程序,code runner 是刚才安装的一个插件,用处是一键编译运行程序,极其方便
  //font size
  "editor.fontSize": 17, // 默认字体大小
  "editor.fontFamily": "monospace",
}

windows

{
  // tab 大小为4个空格
  "editor.tabSize": 4,
  // 编辑器换行
  "editor.wordWrap": "off",
  //code runner
  "code-runner.executorMap": {
    "javascript": "node",
    "java": "cd $dir \n javac $fileName \n java $fileNameWithoutExt",
    "c": "cd $dir \n gcc $fileName -o $fileNameWithoutExt -Wall \n .\\$fileNameWithoutExt", // C 编译命令
    "cpp": "cd $dir \n g++ $fileName -o $fileNameWithoutExt -std=c++11 -Wall \n .\\$fileNameWithoutExt", // C++ 编译命令
    "objective-c": "cd $dir \n gcc -framework Cocoa $fileName -o $fileNameWithoutExt \n .\\$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 \n rustc $fileName \n $dir$fileNameWithoutExt",
    "racket": "racket",
    "ahk": "autohotkey",
    "autoit": "autoit3",
    "dart": "dart",
    "pascal": "cd $dir \n fpc $fileName \n $dir$fileNameWithoutExt",
    "d": "cd $dir \n dmd $fileName \n $dir$fileNameWithoutExt",
    "haskell": "runhaskell",
    "nim": "nim compile --verbosity:0 --hints:off --run",
    "lisp": "sbcl --script",
    "kit": "kitc --run"
  },
  "code-runner.runInTerminal": true, // 让 code runner 在终端中运行程序,code runner 是刚才安装的一个插件,用处是一键编译运行程序,极其方便
  //font size
  "editor.fontSize": 20, // 默认字体大小
  "terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
}

编译运行程序

点击右上角的右三角形

更多设置

点击左下角的设置图标,点击设置,进入设置页面,找到你要设置的条目,点击左边的齿轮,复制它的json信息,粘贴到settings.json中。

posted @ 2019-04-18 10:53  chc_1234567890  阅读(1649)  评论(0编辑  收藏  举报