一、vscode安装

1. 下载

  1. 首先进入vscode官方网站然后选择对应版本下载
  1. Download Visual Studio Code - Mac, Linux, Windows】直接点[download]也行
  1. 然后进入浏览器下载页面
  2. 复制下载链接粘贴到地址栏
  3. 将地址中的/stable前换成vscode.cdn.azure.cn
    即可实现超速下载

2. 安装

记得勾选全部(右键文件夹和文件能够[通过code打开真的很方便好吧])

vscode mac配置环境python vscode for mac配置c++环境_ide

二、c/c++配置

1. 基本设置(汉化、基本设置)

  1. 中文界面设置:
  1. 下载插件:Chinese Language......
  1. 设置:[文件][首选项][设置]
  2. 打开命令面板:CTRL shift p 
  1. 调出用于执行命令的输入框,这些命令来自VSCode自带已经插件扩展的命令

2. 下载

1. mingw——编译环境

  1. mingw官网【MinGW-w64】——[download][Sources——sourceforge]
  2. 到了sourceforge官网:找到合适exe或者二进制安装包
  3. 下载后进行环境变量配置
  1. 把[bin]的路径添加到[path]中去

一步到位:

MinGW-w64 - for 32 and 64 bit Windows】找到二进制形式的安装包【x86_64-win32-seh】即可

2. 插件—— 代码提示等功能

  1. c/c++:选择版本【1.8.4】
  1. 会自动生成   
  1. launch.json   [debug的配置文件]
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc.exe - 生成和调试活动文件",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "console":"externalTerminal",
            // "externalConsole": true,
            // "MIMode": "gdb",
            // "miDebuggerPath": "D:\\ComApplications\\minGW\\mingw64\\bin\\gdb.exe",
            // "setupCommands": [
            //     {
            //         "description": "为 gdb 启用整齐打印",
            //         "text": "-enable-pretty-printing",
            //         "ignoreFailures": true
            //     },
            //     {
            //         "description": "将反汇编风格设置为 Intel",
            //         "text": "-gdb-set disassembly-flavor intel",
            //         "ignoreFailures": true
            //     }
            // ],
            "preLaunchTask": "C/C++: gcc.exe 生成活动文件"
        }
    ]
}
  1. tasks.json  [运行的运行文件](如果修改了全局编码,这个配置文件就不用动了)
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe 生成活动文件",
            "command": "D:\\ComApplications\\minGW\\mingw64\\bin\\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-fexec-charset=GBK"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}
  1. 但是需要修改(修改后见上)

3. 文件运行(不用看上面的 插件)

1. 【完美配置vscode运行c/c++环境

2.【VS Code中C/CPP的完美配置

  1. 对【code runner】扩展进行配置
  2. 对【c/c++】扩展进行配置
  3. 对配置文件进行修改
  1. launch.json
{
    "version":"0.2.0",
    "configurations":[
        {
    "name":"g++.exe build and debug active file",
    "type":"cppdbg",
    "request":"launch",
    // "program":"C:\\Windows\\system32\\cmd.exe",
    // "args":["/C","${fileDirname)\\${fileBasenameNoExtension}.exe","&","pause"],
    "program": "C:\\Windows\\system32\\cmd.exe",
    "args":["/C","${fileDirname}\\${fileBasenameNoExtension}.exe","&","pause"],
    "stopAtEntry":false,
    // "cwd":"${workspaceFolder}",
    "cwd":"${fileDirname}",
    "environment":[],
    "externalConsole":true,
    "MIMode":"gdb",
    "miDebuggerPath":"D:\\ComApplications\\minGW\\mingw64\\bin\\gdb.exe",
    "setupCommands":[
    {
    "description":"为gdb启用整济打印",
    "text":"-enable-pretty-printing",
    "ignoreFailures":true

    }
],
    "preLaunchTask":"c/cpp task"
    },
    {
    "name":"debug",
    "type":"cppdbg",
    "request":"launch",
    "program":"${workspaceFolder}/${fileBasenameNoExtension}.exe",
    "args":[],
    "stopAtEntry":false,
    "cwd":"${fileDirname}",
    "environment":[],
    "externalConsole":true,
    "MIMode":"gdb",
    "miDebuggerPath":"D:\\ComApplications\\minGW\\mingw64\\bin\\gdb.exe",
    "setupCommands":[
    {
     "description":"Enable pretty-printing for gdb",
     "text":"-enable-pretty-printing",
      "ignoreFailures":false
    }
],
    "preLaunchTask":"c/cpp task"
    }
    ]
}
  1. tasks.json
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "c/cpp task",
            "command": "D:\\ComApplications\\minGW\\mingw64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}


// {
//     // /有关tasks.json格式的文档,请参见
//     // /https://go.microsoft.com/fwlink/?LinkId=733558
//     "version":"2.0.0",
//     "tasks":[
//     {
//     "type":"shell",
//     "label":"c/cpp task",
//     "command":"D:\\ComApplications\\minGW\\mingw64\\bin\\g++.exe",
//     "args":[
//     "-g",
//     "${file}",
//     "-o",
//     "${fileDirname}\\${fileBasenameNoExtension}.exe"
//     ],
//     "options":{
//     "cwd":"D:\\ComApplications\\minGW\\mingw64\\bin"
//     },
//     "problemMatcher":[
//     "$gcc"
//     ],
//     "group":"build"
//     },

// {
// "type":"shell",
// "label":"c/cpp task",
// "command":"D:\\ComApplications\\minGW\\mingw64\\bin\\g++.exe",
// "args":[
// "-0",
// "${fileBasenameNoExtension}",
// "${fi1e}"
// ],
// "group":{
// "kind":"build",
// "isDefault":true
// }}]}

3. 专业术语说明

  1. [gcc]:由GNU开发的编程语言编译器
  2. [GNU]:一个操作系统,其内容软件完全以GPL方式发布
  3. [GPL]:GNU通用公共许可证,使用该证书的软件被称为自由软件
  4. [自由软件]
  1. 区别:[自由软件、开源软件、免费软件之间的区别]

4. 相关问题

如何彻底卸载?  ——包括打开的文件夹、安装过的扩展等

在卸载之后再删除掉两个目录的内容。分别是:

  • C:\Users\$用户名\.vscode
  • C:\Users\$用户名\AppData\Roaming\Code【注】这里的“$用户名”根据自己的用户名而定。