Created
October 16, 2023 14:08
-
-
Save 71/557b4aa0dbda88e6f8eadfb96cdba4ab to your computer and use it in GitHub Desktop.
C++ include guard VS Code snippet: replace special characters with _, make upper case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"New C++ header": { | |
"prefix": "newh", | |
"body": [ | |
// VS Code snippets do not support recursive replacements so we must be | |
// creative: replace segments like `foo/`, `bar.` and `h<eos>` to `FOO_`, | |
// `BAR_` and `H_` such that `foo/bar.h` becomes `FOO_BAR_H_`. | |
"#ifndef PROJECT_${RELATIVE_FILEPATH/(\\w+)(?:\\.|\\/|$)/${1:/upcase}_/g}", | |
"#define PROJECT_${RELATIVE_FILEPATH/(\\w+)(?:\\.|\\/|$)/${1:/upcase}_/g}", | |
"", | |
"namespace project {", | |
"", | |
"$0", | |
"", | |
"} // namespace project", | |
"", | |
"#endif // PROJECT_${RELATIVE_FILEPATH/(\\w+)(?:\\.|\\/|$)/${1:/upcase}_/g}" | |
], | |
"isFileTemplate": true, | |
"scope": "cpp", | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment