zoukankan      html  css  js  c++  java
  • Windows & Ubuntu Vscode 配置c++环境

    背景

    被三岁神仙 (color{black}{ ext{Q}}color{red}{ ext{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 
     javac $fileName 
     java $fileNameWithoutExt",
        "c": "cd $dir 
     gcc $fileName -o $fileNameWithoutExt -Wall 
     .\$fileNameWithoutExt", // C 编译命令
        "cpp": "cd $dir 
     g++ $fileName -o $fileNameWithoutExt -std=c++11 -Wall 
     .\$fileNameWithoutExt", // C++ 编译命令
        "objective-c": "cd $dir 
     gcc -framework Cocoa $fileName -o $fileNameWithoutExt 
     .\$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": 20, // 默认字体大小
      "terminal.integrated.shell.windows": "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
    }
    

    编译运行程序

    点击右上角的右三角形

    更多设置

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

  • 相关阅读:
    【HICP Gaussdb】数据库 数据库管理( 导入 导出 闪回 调优 wsr报告 ) -13
    【Flask项目】 python学习第一章
    【Flask项目】 python学习第一章
    【HICP Gaussdb】数据库 数据库管理( 备份 导入 导出 ) -12
    【系统级配置】/etc/sysctl.conf
    【Flask项目】 python学习第一章
    【HICP Gaussdb】数据库 数据库管理( 数据库安全 账户 日志管理)-11
    【Git】 python学习第一章
    【HICP Gaussdb】数据库 数据库管理(并发 锁 数据库安全)-10
    【HCIA Gauss】学习汇总-数据库管理(三范式 GAUSSDB100)-8
  • 原文地址:https://www.cnblogs.com/BlogOfchc1234567890/p/10728309.html
Copyright © 2011-2022 走看看