《关于我重装系统后修复VSCode这档事》C++环境配置

不哔哔,切入正题,参考网络大神的方法,记录我的实践心得
1.配置过程:VSCode C/C++语言环境自动配置 半分钟部署环境 保证小白一看就会_哔哩哔哩_bilibili
2.工具箱:【一键】20秒配置VScodeC语言C++开发环境!免费开源_哔哩哔哩_bilibili
工具箱下载地址:Release AutoVsCEnv_WPF V1.994 · SDchao/AutoVsCEnv_WPF · GitHub
本地CSDN下载:VSCodeC++环境一键配置-其它文档类资源-CSDN下载
(如果有密码就是asd)

 部署自定义背景后,setting.json 部署参考文章末尾

使用前记得退出360,它似乎会阻拦环境变量的配置

最终结果:让大家拥有和我一样快乐的编译环境
        1.可以在vscode写C++文件
        2.C++在内置终端运行,不会生成碍眼的exe
        3.基础性的调试能力,断电测试能力
        4.非常舒服的快捷键,和内置资源结构管理

第一步:下载VSCode,部署内置插件

        按照视频做就好,我自己电脑的vscode安装路径
"C:\ASRC\VSCode\Microsoft VS Code\Code.exe"

 

第二步:个性化的快捷键部署

        推荐一下我自己喜欢的快捷键:
        1.  Alt + 1 3        左/右 切换  代码页
        2.  Alt + 2           关闭           代码页
        3.  Alt +  '+' /‘-’    放大/缩小   字体
        4.  Ctrl + '+'/'-'     放缩整个页面(包括字体)

 

第三步:启用工具箱,自动部署MINGW

 

 

 

 因为我已经配置好了就不用下一步了,第一个mingw64是配置mingw的路径
这个工具会帮你添加path,不需要你再去环境变量配置

工具运行后结果

 VSCode,打开test工作区,文件夹拖过去

第四步:json配置修复

这一步修复后,可以 1.文件自动保存 2.支持中文路径 3.终端内运行 且 不出现exe强迫症の快乐

run code 插件中json的修复

 

赋值一下代码,前面加上rm,后面加上.exe  给C和CPP都部署上去即可 

 把下面几个打钩都打上

第五步:编译环境再优化

浅浅的跑一下,没有问题

换个中文路径,再跑,也没有问题

 ACM文件夹中四个工作json的参考

c_cpp_properties

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/mingw64/include/*"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:/mingw64/bin/gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "x86",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "miDebuggerPath": "C:/mingw64/bin/gdb.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "externalConsole": true,
            "preLaunchTask": "g++"
        }
    ]
}

setting.json

{
    "files.associations": {
        "algorithm": "cpp",
        "array": "cpp",
        "atomic": "cpp",
        "*.tcc": "cpp",
        "bitset": "cpp",
        "cctype": "cpp",
        "cfenv": "cpp",
        "charconv": "cpp",
        "chrono": "cpp",
        "cinttypes": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "codecvt": "cpp",
        "complex": "cpp",
        "condition_variable": "cpp",
        "csetjmp": "cpp",
        "csignal": "cpp",
        "cstdarg": "cpp",
        "cstddef": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cuchar": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "deque": "cpp",
        "forward_list": "cpp",
        "list": "cpp",
        "unordered_map": "cpp",
        "unordered_set": "cpp",
        "vector": "cpp",
        "exception": "cpp",
        "functional": "cpp",
        "iterator": "cpp",
        "map": "cpp",
        "memory": "cpp",
        "memory_resource": "cpp",
        "numeric": "cpp",
        "optional": "cpp",
        "random": "cpp",
        "ratio": "cpp",
        "regex": "cpp",
        "set": "cpp",
        "string": "cpp",
        "string_view": "cpp",
        "system_error": "cpp",
        "tuple": "cpp",
        "type_traits": "cpp",
        "utility": "cpp",
        "fstream": "cpp",
        "future": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "iosfwd": "cpp",
        "iostream": "cpp",
        "istream": "cpp",
        "limits": "cpp",
        "mutex": "cpp",
        "new": "cpp",
        "ostream": "cpp",
        "scoped_allocator": "cpp",
        "shared_mutex": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "streambuf": "cpp",
        "thread": "cpp",
        "typeindex": "cpp",
        "typeinfo": "cpp",
        "valarray": "cpp",
        "Test_.C": "cpp",
        "queue": "cpp"
    }
}

tasks.json

{
  "version": "2.0.0",
  "command": "g++",
  "type": "shell",
  "presentation": {
    "echo": true,
    "reveal": "always",
    "focus": false,
    "panel": "shared",
    "showReuseMessage": true,
    "clear": false
  },
  "args": ["-m32","-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}.exe"],
  "problemMatcher": {
    "owner": "cpp",
    "fileLocation": ["relative", "${workspaceRoot}"],
    "pattern": {
      "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
      "file": 1,
      "line": 2,
      "column": 3,
      "severity": 4,
      "message": 5
    }
  }
}

 调试测试,没用过,现学现卖

在这里结束,感谢网络上大佬分享的教程让我得到学习,我也愿意与你们一同分享实践过程!

workbench.colorCustomizations,然后打开settings.json设置文件(高亮选中部署

"workbench.colorCustomizations": {
        "editor.selectionHighlightBackground": "#288603",
        "editor.selectionBackground":"#288603",
        
    }

全局setting.json(已经部署background插件与相关主题)

{
    "workbench.iconTheme": "vscode-icons",
    "files.encoding": "gbk",
    "files.autoSave": "afterDelay",
    "bracket-pair-colorizer-2.depreciation-notice": false,
    "explorer.confirmDelete": false,
    "code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && rm $dir$fileNameWithoutExt.exe",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && rm $dir$fileNameWithoutExt.exe",
        "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",
        "scheme": "csi -script",
        "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",
        "v": "v run",
        "sass": "sass --style expanded",
        "scss": "scss --style expanded",
        "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
        "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
    },
    "code-runner.runInTerminal": true,
    "code-runner.saveFileBeforeRun": true,
    "code-runner.saveAllFilesBeforeRun": true,
    "editor.unicodeHighlight.allowedLocales": {
        "zh-hant": true
    },
    "workbench.colorTheme": "escook Dark",
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "editor.fontSize": 18,
    "explorer.confirmDragAndDrop": false,
    "workbench.colorCustomizations": {
        "editor.selectionHighlightBackground": "#288603",
        "editor.selectionBackground": "#288603",
    },
    "vsicons.dontShowNewVersionMessage": true,
    "[cpp]": {
        "editor.defaultFormatter": "ms-vscode.cpptools"
    },
    "workbench.layoutControl.enabled": false,
    "background.enabled": true,//增强部署,删除后恢复
    "background.useDefault": false,//增强部署,删除后恢复
    "background.customImages": [//部署的多张图片,会在分屏代码时候轮番上阵,据说最多部署3张
        "file:///C:/计算机核心/PC Res/长期文件/壁纸库/back4.png"
        "file:///C:/计算机核心/PC Res/长期文件/壁纸库/back3.png"
        "file:///C:/计算机核心/PC Res/长期文件/壁纸库/back2.png"//同样是增强部署
    ],
    "background.style": {
    
    
        "content": "''",
        "pointer-events": "none",
        "position": "absolute",
        "z-index": "99999",
        "width": "100%",
        "height": "100%",
        "background-position": "0% 30%",
        "background-repeat": "no-repeat",
        "opacity": 1
    },
    "workbench.startupEditor": "none",
    "background.fullscreen": {




        "image": "",
        "opacity": 0.91,
        "size": "cover"
    },
    "workbench.statusBar.visible": false,
    "open-in-browser.default": "firefox",
    "workbench.activityBar.visible": false
}

部分插件推荐

 

 

win + ;    调出emoji表情包

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: 如果 vscode 无法打开 iostream 源文件,可能的原因有: 1. 可能是编译器的问题,确认您是否安装了正确的编译器并且配置好了 vscode。 2. 可能是源文件的路径问题,确认您是否在正确的目录中查找源文件。 3. 可能是 vscode 的配置问题,检查您的 vscode 设置是否正确。 4. 可能是代码中有语法错误,请检查您的代码。 建议您按照这些建议检查问题,如果问题仍然存在,请提供更多信息以便进一步分析问题。 ### 回答2: 在使用VSCode编写C++程序时,发现无法打开源文件iostream,产生这种情况的原因可能是多方面的。以下是一些解决方法。 1. 确定编译器路径:在VSCode中打开终端,使用命令“where g++”来确定g++编译器的路径。确保路径正确,否则需要在“settings.json”或者“tasks.json”中添加正确的编译器路径。 2. 确定文件路径:在文件路径出现问题时,可以使用绝对路径或相对路径。在Windows中,使用斜杠“/”作为路径分割符。在VSCode中打开终端,使用“dir”命令来查看当前目录下的文件,确认文件名和路径是否正确。 3. 确认文件是否存在:如果文件不存在或者路径错误,就会出现无法打开文件的错误。使用“ls”或“dir”命令确认文件是否存在并且路径正确。 4. 确认文件格式:使用VSCode编写C++时,需要使用.cpp格式的文件。如果使用的是其他格式,就无法进行编译。确认文件格式正确后再进行编译。 5. 确认头文件:iostream是C++中的一个标准头文件,因此无需单独安装。但是,如果出现无法打开文件的情况,可以尝试重新安装C++编译器,确保iostream头文件在正确的位置。 以上是一些可能会导致无法打开iostream文件的原因和解决方法。如果以上方法无法解决问题,就需要寻找其他原因并解决问题。 ### 回答3: Visual Studio Code是一款开源的跨平台代码编辑器,它可以用于多种编程语言,包括C++。在使用Visual Studio Code进行C++开发时,可能会出现无法打开源文件iostream的问题。 iostream是C++标准库中的输入输出流库,它提供了cin和cout等常用的输入输出函数。如果在使用Visual Studio Code时无法打开iostream库,可能是由于缺少相应的头文件或者库文件。 解决这个问题的方法是首先确认自己的C++开发环境是否已经正确地安装和配置好。然后检查代码中是否正确地引用了iostream头文件。如果头文件引用没有问题,可以尝试更新C++编译器,或者手动添加iostream库文件的路径。 另外,还需要注意的是,编译器和IDE的版本也可能会影响到iostream库的使用。如果在使用Visual Studio Code时无法打开iostream库,可以尝试使用其他版本的编译器和IDE,或者安装相关的补丁和更新。 总之,如果遇到无法打开源文件iostream的问题,需要仔细检查代码和开发环境的配置,并尝试通过更新编译器和IDE等方法来解决。只有正确地配置好开发环境和代码,才能顺利地进行C++开发工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

影月丶暮风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值