Visual Studio 2019 & Visual Studio Code & Codeblocks设置

图片镇Blog

有需要MinGW64 MinGW安装包、Codeblocks主题文件和汉化文件的,评论,发

Visual Studio 2019

密钥

Visual Studio 2019 Enterprise
BF8Y8-GN2QH-T84XB-QVY3B-RC4DF

Visual Studio 2019 Professional
NYWVH-HT4XC-R2WYW-9Y3CM-X4V3Y

1、自动填充格式设置

状态栏选择“工具”选项 --> 选项 --> 文本编辑器 --> c/c++ -->格式设置–>常规
Visual Studio 2019 & Visual Studio Code & Codeblocks设置_第1张图片
设置完之后就不会自动填充格式了。

2、 scanf不支持,编译报错

错误 C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Visual Studio 2019 & Visual Studio Code & Codeblocks设置_第2张图片
Visual Studio 2019 & Visual Studio Code & Codeblocks设置_第3张图片
在上图所圈处更换下面代码:

WIN32
_DEBUG
_CONSOLE
_CRT_SECURE_NO_WARNINGS

确定、确定…就好了
但是仍会出现scanf返回值警告,毕竟不是error,所以不用在意。

3、插件

  • Visual Studio IntelliCode
    提供代码智能提示
  • One Dark Pro
    主题颜色
  • RockMargin
    代码侧边显示缩略图,不建议安装
  • Solution Error Visualizer
    错位显示定位
  • Viasfora
    增加代码颜色

4、 设置侧边缩略图显示

工具-->选项-->文本编辑器-->选择对应的语言-->滚动条-->(行为设置下)使用垂直滚动条的缩略图模式-->确定
Visual Studio 2019 & Visual Studio Code & Codeblocks设置_第4张图片

Visual Studio Code设置

C/C++编译环境

1、MinGW的安装
2、系统环境变量的设置
3、c/c++插件的安装

4、配置

launch.json的配置

{
     
    "version": "0.2.0",
    "configurations": [{
     
        // 配置 VS Code 调试行为:
        "name": "GDB Debug", // 设置在启动配置下拉菜单中显示调试配置的名称。
        "preLaunchTask": "Compile", // 调试会话开始前要运行的任务。
        "type": "cppdbg", // 设置要使用的基础调试器。使用 GDB 或 LLDB 时必须是 cppdbg 。
        "request": "launch", // 设置启动程序还是附加到已经运行的实例。启动或附加 ( launch | attach ).
        "program": "${fileDirname}/${fileBasenameNoExtension}.exe", // 调试器将启动或附加的可执行文件的完整路径。
        "externalConsole": true, // 设置是否显示外部控制台。
        "logging": {
      // 用于确定应该将哪些类型的消息记录到调试控制台。
            "exceptions": true, // 是否应将异常消息记录到调试控制台。默认为真。
            "moduleLoad": false, // 是否应将模块加载事件记录到调试控制台。默认为真。
            "programOutput": true, // 是否应将程序输出记录到调试控制台的可选标志。默认为真。
            "engineLogging": false, // 是否应将诊断引擎日志记录到调试控制台。默认为假。
            "trace": false, // 是否将诊断适配器命令跟踪记录到调试控制台。默认为假。
            "traceResponse": false // 是否将诊断适配器命令和响应跟踪记录到调试控制台。默认为假。
        },
        // 配置目标应用程序:
        "args": [], // 设置调试时传递给程序的命令行参数。
        "cwd": "${workspaceFolder}", // 设置调试器启动的应用程序的工作目录。
        "environment": [], // 设置调试时添加到程序环境中的环境变量,例如: [ { "name": "squid", "value": "clam" } ]。
        // 自定义 GDB 或者 LLDB:
        "windows": {
     
            "MIMode": "gdb", // 指定 VS Code 连接的调试器,必须为 gdb 或者 lldb。
            "miDebuggerPath": "C:/MinGW/bin/gdb.exe" // 调试器的路径,修改为你的安装路径
        },
        "miDebuggerArgs": "", // 传递给调试器的附加参数
        "stopAtEntry": false, // 设置调试器是否停止在目标的入口(附加时忽略)。默认值为 false。
        "setupCommands": [{
      // 执行下面的命令数组以设置 GDB 或 LLDB
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing", // 鼠标悬停查看变量的值,需要启用 pretty-printing 。
            "ignoreFailures": true // 忽略失败的命令,默认为 false 。
        }]
    }]
}

task.json的配置

{
     
    // 有关 tasks.json 格式的参考文档:https://go.microsoft.com/fwlink/?LinkId=733558 。
    "version": "2.0.0",
    "tasks": [{
     
        "label": "Compile",
        "type": "shell", // { shell | process }
        // 适用于 Windows 的配置:
        "windows": {
     
            "command": "gcc",
            "args": [
                "-g",
                "\"${file}\"",
                "-o",
                "\"${fileDirname}\\${fileBasenameNoExtension}.exe\""
                // 设置编译后的可执行文件的字符集为 GB2312:
                // "-fexec-charset", "GB2312"
                // 直接设置命令行字符集为 utf-8:
                // chcp 65001
            ]
        },
        // 定义此任务属于的执行组:
        "group": {
     
            "kind": "build", // { build | test }
            "isDefault": true // { true | false }
        },
        // 定义如何在用户界面中处理任务输出:
        "presentation": {
     
            // 控制是否显示运行此任务的面板。默认值为 "always":
            // - always:    总是在此任务执行时显示终端。
            // - never:     不要在此任务执行时显示终端。
            // - silent:    仅在任务没有关联问题匹配程序且在执行时发生错误时显示终端
            "reveal": "silent",
            // 控制面板是否获取焦点。默认值为 "false":
            "focus": false,
            // 控制是否将执行的命令显示到面板中。默认值为“true”:
            "echo": false,
            // 控制是否在任务间共享面板。同一个任务使用相同面板还是每次运行时新创建一个面板:
            // - shared:     终端被共享,其他任务运行的输出被添加到同一个终端。
            // - dedicated:  执行同一个任务,则使用同一个终端,执行不同任务,则使用不同终端。
            // - new:        任务的每次执行都使用一个新的终端。
            "panel": "dedicated"
        },
        // 使用问题匹配器处理任务输出:
        "problemMatcher": {
     
            // 代码内问题的所有者为 cpp 语言服务。
            "owner": "cpp",
            // 定义应如何解释问题面板中报告的文件名
            "fileLocation": [
                "relative",
                "${workspaceFolder}"
            ],
            // 在输出中匹配问题的实际模式。
            "pattern": {
     
                // The regular expression.
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                // 第一个匹配组匹配文件的相对文件名:
                "file": 1,
                // 第二个匹配组匹配问题出现的行:
                "line": 2,
                // 第三个匹配组匹配问题出现的列:
                "column": 3,
                // 第四个匹配组匹配问题的严重性,如果忽略,所有问题都被捕获为错误:
                "severity": 4,
                // 第五个匹配组匹配消息:
                "message": 5
            }
        }
    }]
}

5、第二种配置

切记修改自己的编译器路径
配置launch

{
     
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
     
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe",/*待修改*/
            "setupCommands": [
                {
     
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

配置task

{
     
	"version": "2.0.0",
	"tasks": [
		{
     
			"type": "shell",
			"label": "C/C++: g++.exe build active file",
			"command": "C:\\mingw64\\bin\\g++.exe",/*待修改*/
			"args": [
				"-g",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe"
			],
			"options": {
     
				"cwd": "C:\\mingw64\\bin"/*待修改*/
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
     
				"kind": "build",
				"isDefault": true
			}
		}
	]
}

Codeblocks

1、设置字体类型、大小、颜色

路径:Settings-->Editor-->General Settings-->Choose
推荐字体:Consoals
Visual Studio 2019 & Visual Studio Code & Codeblocks设置_第5张图片
Visual Studio 2019 & Visual Studio Code & Codeblocks设置_第6张图片

2、设置背景颜色

路径:Settings-->Editor-->General Settings-->Choose
Visual Studio 2019 & Visual Studio Code & Codeblocks设置_第7张图片

3、设置主题包

全局搜索default.conf
一般默认安装情况下,该文件的位置在:C:\Users\你的电脑名字\AppData\Roaming\CodeBlocks下,里面中文记得替换啊
直接将含有多种主题的文件进行替换即可,重启Codeblocks生效
注意:建议先备份下原有的文件,万一出现错误呢?

你可能感兴趣的:(Visual Studio 2019 & Visual Studio Code & Codeblocks设置)