Windows & Ubuntu Vscode 配置c++環境

背景

被三歲神仙 \(\color{black}{\text{Q}}\color{red}{\text{Y}}\) 使用了rm -rf *(還好有備份)javascript

安裝

首先裝一個叫作ubuntu make的東西:php

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

而後用它java

umake web visual-studio-code

中間會有一個詢問,輸入a+回車node

卸載

umake web visual-studio-code --remove

配置中文環境

點一下左邊菜單上從上往下第5個(一個方形),查找並安裝Chinese (Simplified) Language Pack for Visual Studio Code插件,而後重啓vscodepython

打開一個文件/文件夾

在首頁點擊打開文件打開文件夾linux

配置c++環境

安裝如下插件:c++

點擊左下角的設置圖標,點擊設置,進入設置頁面,再點擊右上角的大括號{},進入settings.json的文件,在裏面輸入:
linuxweb

{
  // 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 // 默認字體大小
}

windowsobjective-c

{
  // 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"
}

編譯運行程序

點擊右上角的右三角形typescript

更多設置

點擊左下角的設置圖標,點擊設置,進入設置頁面,找到你要設置的條目,點擊左邊的齒輪,複製它的json信息,粘貼到settings.json中。

相關文章
相關標籤/搜索