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中。

  • 相关阅读:
    171 01 Android 零基础入门 03 Java常用工具类02 Java包装类 01 包装类简介 01 Java包装类内容简介
    170 01 Android 零基础入门 03 Java常用工具类01 Java异常 08 Java异常总结 01 异常总结
    169 01 Android 零基础入门 03 Java常用工具类01 Java异常 07 异常链 01 异常链简介
    168 01 Android 零基础入门 03 Java常用工具类01 Java异常 06 自定义异常 01 自定义异常类
    167 01 Android 零基础入门 03 Java常用工具类01 Java异常 05 使用throw和throws实现异常处理 02 使用throw抛出异常对象
    166 01 Android 零基础入门 03 Java常用工具类01 Java异常 05 使用throw和throws实现异常处理 01 使用throws声明异常类型
    165 01 Android 零基础入门 03 Java常用工具类01 Java异常 04 使用try…catch…finally实现异常处理 05 return关键字在异常处理中的使用
    DevExpress WPF v20.2版本亮点放送:全新升级的PDF Viewer
    界面控件DevExpress使用教程:Dashboard – 自定义导出
    DevExpress WinForms帮助文档:表单控件
  • 原文地址:https://www.cnblogs.com/BlogOfchc1234567890/p/10728309.html
Copyright © 2011-2022 走看看