2012-08-16 23:41:25 -04:00
|
|
|
###########################################################################
|
|
|
|
# TextMate Snippets #
|
|
|
|
###########################################################################
|
2013-04-13 13:45:21 -04:00
|
|
|
|
2014-03-11 16:10:50 -04:00
|
|
|
priority -50
|
|
|
|
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet def "#define ..."
|
|
|
|
#define ${1}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ifndef "#ifndef ... #define ... #endif"
|
2012-08-16 23:41:25 -04:00
|
|
|
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
|
|
|
|
#define ${1:SYMBOL} ${2:value}
|
|
|
|
#endif
|
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 16:10:50 -04:00
|
|
|
snippet #if "#if #endif" b
|
2012-08-16 23:41:25 -04:00
|
|
|
#if ${1:0}
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
#endif
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet inc "#include local header (inc)"
|
|
|
|
#include "${1:`!p snip.rv = snip.basename + '.h'`}"
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet Inc "#include <> (Inc)"
|
|
|
|
#include <${1:.h}>
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet mark "#pragma mark (mark)"
|
|
|
|
#if 0
|
|
|
|
${1:#pragma mark -
|
|
|
|
}#pragma mark $2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet main "main() (main)"
|
2014-03-11 16:10:50 -04:00
|
|
|
int main(int argc, char *argv[])
|
2012-08-16 23:41:25 -04:00
|
|
|
{
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 16:10:50 -04:00
|
|
|
snippet for "for loop (for)"
|
|
|
|
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
|
|
|
{
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2014-03-11 16:10:50 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet fori "for int loop (fori)"
|
|
|
|
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
2012-08-16 23:41:25 -04:00
|
|
|
{
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet enum "Enumeration"
|
|
|
|
enum ${1:name} { $0 };
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet once "Include header once only guard"
|
|
|
|
#ifndef ${1:`!p
|
|
|
|
if not snip.c:
|
|
|
|
import random, string
|
|
|
|
name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper()
|
|
|
|
rand = ''.join(random.sample(string.ascii_letters+string.digits, 8))
|
|
|
|
snip.rv = ('%s_%s' % (name,rand)).upper()
|
|
|
|
else:
|
2014-03-11 16:10:50 -04:00
|
|
|
snip.rv = snip.c`}
|
2012-08-16 23:41:25 -04:00
|
|
|
#define $1
|
|
|
|
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
#endif /* end of include guard: $1 */
|
|
|
|
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet td "Typedef"
|
|
|
|
typedef ${1:int} ${2:MyCustomType};
|
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 16:10:50 -04:00
|
|
|
snippet wh "while loop"
|
|
|
|
while(${1:/* condition */}) {
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2014-03-11 16:10:50 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet do "do...while loop (do)"
|
|
|
|
do {
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
} while(${1:/* condition */});
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet fprintf "fprintf ..."
|
|
|
|
fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet if "if .. (if)"
|
|
|
|
if (${1:/* condition */})
|
|
|
|
{
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2014-03-11 16:10:50 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet el "else .. (else)"
|
|
|
|
else {
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2014-03-11 16:10:50 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet eli "else if .. (eli)"
|
|
|
|
else if (${1:/* condition */}) {
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet ife "if .. else (ife)"
|
|
|
|
if (${1:/* condition */})
|
|
|
|
{
|
2014-07-02 07:18:18 -04:00
|
|
|
${2}
|
2013-04-13 13:45:21 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-11 16:10:50 -04:00
|
|
|
${3:/* else */}
|
2013-04-13 13:45:21 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet printf "printf .. (printf)"
|
|
|
|
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet st "struct"
|
|
|
|
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`}
|
|
|
|
{
|
|
|
|
${0:/* data */}
|
|
|
|
};
|
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 16:10:50 -04:00
|
|
|
snippet fun "function" b
|
|
|
|
${1:void} ${2:function_name}(${3})
|
|
|
|
{
|
2014-07-02 07:18:18 -04:00
|
|
|
${VISUAL}${0}
|
2014-03-11 16:10:50 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet fund "function declaration" b
|
|
|
|
${1:void} ${2:function_name}(${3});
|
|
|
|
endsnippet
|
|
|
|
|
2012-08-16 23:41:25 -04:00
|
|
|
# vim:ft=snippets:
|