在Vscode中,按快捷键Ctrl+Shift+P
搜索snippets命令,选择“代码片段:配置用户代码片段”
选择“新建全局代码片段文件”
新建名称:add 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 /* __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__ */"
]
}
}
创建好后在.c和.h文件中直接输入:add header即可
标签:__,头文件,VScode,FILENAME,header,endif,ifndef,define From: https://www.cnblogs.com/siky/p/18207911