文章目录
VS Code安装
安装包
VS Code基础配置
Setting | Function |
---|---|
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.youkuaiyun.com/maokelong95/article/details/54379046