command + shift + p
C/C++:编辑配置(JSON)
查看头文件路径
gcc -v -x c -E -
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include",
"/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1",
"/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
"/Library/Developer/CommandLineTools/usr/include",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64"
}
],
"version": 4
}
command + shift + B
选择others
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build with Clang",
"type": "shell",
"command": "clang++",
"args": [
"${file}",
"-std=c++11",
"-o",
"${workspaceFolder}/out/${fileBasenameNoExtension}.out",
"-g",
"--debug"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "lldb",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal",
"MIMode": "lldb"
}
]
}
{
"C_Cpp.updateChannel": "Insiders",
"leetcode.endpoint": "leetcode-cn",
"leetcode.defaultLanguage": "cpp",
"leetcode.workspaceFolder": "/Users/whois/leetcode",
"leetcode.editor.shortcuts": [
"submit",
"test",
"description",
"solution"
],
"markdown.preview.fontSize": 16,
"leetcode.hint.configWebviewMarkdown": false,
"leetcode.hint.commandShortcut": false,
"leetcode.hint.commentDescription": false,
"editor.fontSize": 14,
"debug.onTaskErrors": "showErrors",
"workbench.colorTheme": "Dracula",
"workbench.preferredDarkColorTheme": "Dracula Soft",
"debug.allowBreakpointsEverywhere": true,
"explorer.confirmDelete": false,
"editor.codeActionsOnSave": null,
"code-runner.executorMap": {
"cpp": "cd $dir && g++ $fileName -o /Users/whois/leetcode/out/$fileNameWithoutExt && /Users/whois/leetcode/out/$fileNameWithoutExt",
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"php": "php",
"python": "python -u",
"perl": "perl",
"perl6": "perl6",
"ruby": "ruby",
"go": "go run",
"lua": "lua",
"groovy": "groovy",
"powershell": "powershell -ExecutionPolicy ByPass -File",
"bat": "cmd /c",
"shellscript": "bash",
"fsharp": "fsi",
"csharp": "scriptcs",
"vbscript": "cscript //Nologo",
"typescript": "ts-node",
"coffeescript": "coffee",
"scala": "scala",
"swift": "swift",
"julia": "julia",
"crystal": "crystal",
"ocaml": "ocaml",
"r": "Rscript",
"applescript": "osascript",
"clojure": "lein exec",
"haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
"racket": "racket",
"scheme": "csi -script",
"ahk": "autohotkey",
"autoit": "autoit3",
"dart": "dart",
"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
"d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
"haskell": "runhaskell",
"nim": "nim compile --verbosity:0 --hints:off --run",
"lisp": "sbcl --script",
"kit": "kitc --run",
"v": "v run",
"sass": "sass --style expanded",
"scss": "scss --style expanded",
"less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
"FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
}
}
安装koroFileHeader插件,然后进入首选项- 设置里搜索 fileheader 进行配置,不配置可以使用默认的。
settings.json中加入
"editor.wordWrap": "on",
"editor.wordWrapColumn": 150,
code -> 首选项 -> 用户片段
输入 c_cpp_header
"C C++ Header": {
"scope": "c, cpp",
"prefix": "header",
"description": "Add #ifndef, #define and #endif",
"body": [
"#ifndef ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H",
"#define ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H",
"",
"$0",
"",
"#endif"
]
}
再来个
"Print to console": {
"prefix": "cpp",//触发条件
"body": [ // 模板内容
"#include ",
"",
"using namespace std;",
"",
"int main()",
"{",
" $0",
" return 0;",
"}",
"",
],
"description": " for cpp template"
}