Skip to content

Instantly share code, notes, and snippets.

@leonid-ed
Forked from Muon/gist:2561013
Last active November 18, 2015 08:16
Show Gist options
  • Save leonid-ed/be1fd9c6e6da89b3d711 to your computer and use it in GitHub Desktop.
Save leonid-ed/be1fd9c6e6da89b3d711 to your computer and use it in GitHub Desktop.
C/C++ header guard snippet for Sublime Text 2/3
<snippet>
<content><![CDATA[
#ifndef ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g}
#define ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g}
$0
#endif // ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>h_guard</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
<scope>source.c</scope>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment