Visual Studio Code安装及配置

VS Code安装

安装包

VS Code基础配置

SettingFunction
files.trimTrailingWhitespace保存文件时删除行尾的空格
C_Cpp.dimInactiveRegions控制非活动预处理程序块的颜色是否与活动代码不同
Editor: Tab Completion启用Tab补全
Editor: Quick Suggestions Delay控制显示快速建议前的等待时间(毫秒)
Editor: Quick Suggestions控制是否在键入时自动显示建议
Editor: Snippet Suggestions控制代码片段是否与其他建议一起显示及其排列的位置
Editor › Suggest: Snippets Prevent Quick Suggestions控制活动代码段是否阻止快速建议
C_Cpp › Default: Cpp Standard指定c++ 版本
Editor: Occurrences Highlight控制光标所在位置变量高亮

.vscode/setting.json

{
    "files.trimTrailingWhitespace": true,
    "editor.tabCompletion": "on",
    "editor.quickSuggestions": true,
    "editor.snippetSuggestions": "inline",
    "editor.suggest.snippetsPreventQuickSuggestions": false,
    "editor.quickSuggestionsDelay": 0,
    "C_Cpp.default.cppStandard": "c++17",
    "editor.renderWhitespace": "all",
    "C_Cpp.default.defines": [
        "LOCAL_ENV"
    ]
}

VS Code插件

TabOut SFTP plantUML LeetCode C/C++ debugpig.highlight

SFTP

.vscode/sftp.json

{
    "name": "My Server",
    "host": "localhost or ip address",
    "protocol": "sftp",
    "port": 22,
    "username": "username",
    "password": "xxx",
    "remotePath": "/",
    "uploadOnSave": false
}

C/C++

.vscode/launch.json

{
    // 使用 IntelliSense 了解相关属性。
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            // "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "program": "${workspaceFolder}/run.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "D:\\MinGW-W64\\install\\mingw64\\bin",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\MinGW-W64\\install\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

.vscode/tasks.json

{
    "tasks": [
        {
            "type": "cppbuild",
            // 注意: label 需要和 launch.json 的 preLaunchTask 相同
            "label": "C/C++: g++.exe build active file",
            "command": "D:\\MinGW-W64\\install\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                /*
                "-std=c++11",
                "-fno-elide-constructors",
                */
                "-std=c++17",
                "-I${workspaceFolder}/contest_prepare",
                "-DLOCAL_ENV",
                "-o",
                // "${fileDirname}\\${fileBasenameNoExtension}.exe"
                "${workspaceFolder}/run.exe"
            ],
            "options": {
                "cwd": "D:\\MinGW-W64\\install\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

Snippets

xxx.code-snippets

{
    // Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
    // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
    // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
    // used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
    // Placeholders with the same ids are connected.
    // Example:
    // "Print to console": {
    // 	"scope": "javascript,typescript",
    // 	"prefix": "log",
    // 	"body": [
    // 		"console.log('$1');",
    // 		"$2"
    // 	],
    // 	"description": "Log output to console"
    // }
    "#ifndef … #define … #endif": {
        "prefix": "def",
        "body": [
            "#ifndef ${1:SYMBOL}",
            "#define $1 ${2:value}",
            "#endif // ${1:SYMBOL}"
        ]
    },
    "#include <>": {
        "prefix": [
            "inc",
            "#inc"
        ],
        "body": "#include <$1>"
    },
    "#include \"\"": {
        "prefix": [
            "Inc",
            "#Inc"
        ],
        "body": "#include \"$1\""
    },
    "Header Include-Guard": {
        "prefix": "hguard",
        "body": [
            "#ifndef ${1:${TM_FILENAME_BASE/(.*)/${1:/upcase}_H/}}",
            "#define $1\n\n$2\n",
            "#endif /* end of include guard: $1 */"
        ]
    },
    "main()": {
        "prefix": "main",
        "body": [
            "int main(int argc, const char *argv[])",
            "{\n\t$0\n\treturn 0;\n}"
        ]
    },
    "inside define for loop": {
        "prefix": [
            "ifor",
            "for"
        ],
        "body": "for (${1:int} ${2:i} = ${3:0}; ${2:i} $4 ${5:count}; ${6:++}${2:i}) {\n\t$0\n}"
    },
    "outside define for loop": {
        "prefix": "ofor",
        "body": "${1:int} ${2:i};\nfor (${2:i} = ${3:0}; ${2:i} $4 ${5:count}; ${6:++}${2:i}) {\n\t$0\n}"
    },
    "Do While Loop": {
        "prefix": "do",
        "body": "do {\n\t$0\n} while($1);"
    },
    "While Loop": {
        "prefix": "while",
        "body": "while ($1) {\n\t$0\n}"
    },
    "Switch Statement": {
        "prefix": "sw",
        "body": "switch ($1) {$2\n\tdefault: {$4\n\t\tbreak;\n\t}\n}"
    },
    "case break": {
        "prefix": "cs",
        "body": "case $1: {$2\n\tbreak;\n}"
    },
    "self comment": {
        "prefix": "scomment",
        "body": [
            "/**${1:\n * @author xxxqiuzh}${2:\n * @time $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND}",
            " * $3",
            " */"
        ]
    }
}

附录

参考链接

https://blog.csdn.net/maokelong95/article/details/54379046

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值