settings.json
{
"editor.formatOnSave": true,
"editor.tabCompletion": "on",
"security.workspace.trust.untrustedFiles": "open",
"C_Cpp.autocompleteAddParentheses": true,
"C_Cpp.default.cppStandard": "c++17",
"C_Cpp.clang_format_style": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 120}",
"C_Cpp.default.intelliSenseMode": "windows-gcc-x64",
}tasks.json
Windows
{
"version": "2.0.0",
"tasks": [
{
"label": "compile single cpp",
"type": "shell",
"command": "g++",
"args": [
"-std=c++17",
"-O2",
"-static",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wconversion",
"-Wshadow",
"-Wfloat-equal",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-D_GLIBCXX_DEBUG",
"-D_GLIBCXX_DEBUG_PEDANTIC",
],
"group": "none",
"presentation": {
"echo": true,
"reveal": "always"
}
},
{
"label": "build and run",
"type": "shell",
"command": "cd /d ${fileDirname} && ${fileBasenameNoExtension}.exe",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"dependsOn": "compile single cpp",
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/d",
"/c"
]
}
}
}
]
}Ubuntu
{
"version": "2.0.0",
"tasks": [
{
"label": "compile single cpp",
"type": "shell",
"command": "g++",
"args": [
"-std=c++17",
"-O2",
"-static",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wconversion",
"-Wshadow",
"-Wfloat-equal",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-D_GLIBCXX_DEBUG",
"-D_GLIBCXX_DEBUG_PEDANTIC"
],
"group": "none",
"presentation": {
"echo": true,
"reveal": "always"
},
"problemMatcher": ["$gcc"]
},
{
"label": "build and run",
"type": "shell",
"command": "${fileBasenameNoExtension}",
"options": {
"cwd": "${fileDirname}"
},
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"dependsOn": "compile single cpp"
}
]
}快捷键
Line Down 改为 Ctrl + D。