Last active
March 1, 2020 00:19
-
-
Save niosus/fac5d94860476b2b4747bc96a5fe7ba5 to your computer and use it in GitHub Desktop.
Define guards snippet for Sublime Text 3
This file contains 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
<snippet> | |
<description>#def_guards_formatted</description> | |
<content><![CDATA[#ifndef ${TM_FILEPATH/(?:^\/*[\w\/]*\/(?:src|include)\/(\w+))|(?:^\/*[\w\/]*\/(\w+)\/(?:\2))|(?:^\/*home\/${TM_FULLNAME}\/(\w+))|(?:\/([\w_]+))|(?:\.(h))/\U$1$2$3$4$5$6_\E/g} | |
#define ${TM_FILEPATH/(?:^\/*[\w\/]*\/(?:src|include)\/(\w+))|(?:^\/*[\w\/]*\/(\w+)\/(?:\2))|(?:^\/*home\/${TM_FULLNAME}\/(\w+))|(?:\/([\w_]+))|(?:\.(h))/\U$1$2$3$4$5$6_\E/g} | |
${0:$SELECTION} | |
#endif // ${TM_FILEPATH/(?:^\/*[\w\/]*\/(?:src|include)\/(\w+))|(?:^\/*[\w\/]*\/(\w+)\/(?:\2))|(?:^\/*home\/${TM_FULLNAME}\/(\w+))|(?:\/([\w_]+))|(?:\.(h))/\U$1$2$3$4$5$6_\E/g} | |
]]></content> | |
<tabTrigger>def</tabTrigger> | |
<scope>source.c, source.c++, source.objc, source.objc++</scope> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For any file of styles:
/home/name/project/src/blah_blah/foo/bar.h
- path hassrc
folder/home/name/project/include/blah_blah/foo/bar.h
- path hasinclude
folder/home/name/project/some_project/some_project/blah_blah/foo/bar.h
- path has a foldersome_project
twice in a row/home/name/blah_blah/foo/bar.h
- none of the abovethis snippet will generate def guards of form:
It will also copy the code you have selected between the markers.