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的文件,在里面输入:

{
  // 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 && $dir$fileNameWithoutExt", // C 编译命令
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -std=c++11 && $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 // 默认字体大小
}

编译运行程序

点击右上角的右三角形

更多设置

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

猜你喜欢

转载自www.cnblogs.com/BlogOfchc1234567890/p/10728309.html