美文网首页
VScode使用二

VScode使用二

作者: 张亦风 | 来源:发表于2019-10-10 11:17 被阅读0次

一、常用的快捷键

1)注释 ctrl+/

  1. 隐藏左侧栏目 ctrl+b

3) 隐藏控制台终端 ctrl+~

4) 新建windows ctrl shift n

5) 折叠区域代码 ctrl shift [ 显示区域代码ctrl shift ]

  1. 缩进ctrl [  和 crtl ]
    

二、编写c++ 配置的文件

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",                                 //配置名称,会在启动配置的下拉菜单中显示
            "type": "cppdbg",                                       //配置类型,只能为cppdbg
            "request": "launch",                                    //请求类型,可以为launch或attach
            "program": "${workspaceFolder}/a.out",             //将要调试的程序的路径
            "args": [],                                             //调试时传递给程序的命令行参数
            "stopAtEntry": false,                                   //设为true程序会暂停在入口处
            "cwd": "${workspaceFolder}",                            //调试程序时的工作目录
            "environment": [],                                      //环境变量
            "externalConsole": true,                                //调试时是否显示控制台窗口
            "MIMode": "gdb",                                        //指定连接的调试器,可以为gdb或lldb
            "miDebuggerPath": "/usr/bin/gdb",                       //gdb路径
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "build"                                //调试开始前执行的任务,一般为编译程序
        }
    ]
}

task.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build", //在launch.json文件中有用到
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "main.cpp"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

按ctrl + shift + P打开vscode控制台(记住此快捷键,以后经常用),输入C/Cpp: Edit configurations,就自动生成了一个c_cpp_properties.json文件,这样你就可以在该文件中编写参数来调整设置。

相关文章

网友评论

      本文标题:VScode使用二

      本文链接:https://www.haomeiwen.com/subject/rmuopctx.html