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 ..."
|
2017-02-11 08:01:38 -05:00
|
|
|
#define $1
|
2013-04-13 13:45:21 -04:00
|
|
|
endsnippet
|
|
|
|
|
2016-03-20 14:01:44 -04:00
|
|
|
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}
|
2015-12-08 08:20:04 -05:00
|
|
|
#endif /* ifndef $1 */
|
2012-08-16 23:41:25 -04:00
|
|
|
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}
|
2017-02-11 08:01:38 -05:00
|
|
|
${VISUAL}$0
|
2012-08-16 23:41:25 -04:00
|
|
|
#endif
|
|
|
|
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
|
|
|
{
|
2017-02-11 08:01:38 -05: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)"
|
2015-07-13 06:22:46 -04:00
|
|
|
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
|
2017-02-11 08:01:38 -05:00
|
|
|
${VISUAL}$0
|
2014-03-11 16:10:50 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet fori "for int loop (fori)"
|
2015-07-13 06:22:46 -04:00
|
|
|
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
|
2017-02-11 08:01:38 -05:00
|
|
|
${VISUAL}$0
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
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
|
|
|
|
|
2017-02-11 08:01:38 -05:00
|
|
|
${VISUAL}$0
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
#endif /* end of include guard: $1 */
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet fprintf "fprintf ..."
|
|
|
|
fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 16:10:50 -04:00
|
|
|
snippet eli "else if .. (eli)"
|
|
|
|
else if (${1:/* condition */}) {
|
2017-02-11 08:01:38 -05:00
|
|
|
${VISUAL}$0
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet printf "printf .. (printf)"
|
|
|
|
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet st "struct"
|
2015-07-13 06:22:46 -04:00
|
|
|
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} {
|
2012-08-16 23:41:25 -04:00
|
|
|
${0:/* data */}
|
|
|
|
};
|
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 16:10:50 -04:00
|
|
|
snippet fun "function" b
|
2017-02-11 08:01:38 -05:00
|
|
|
${1:void} ${2:function_name}($3)
|
2014-03-11 16:10:50 -04:00
|
|
|
{
|
2017-02-11 08:01:38 -05:00
|
|
|
${VISUAL}$0
|
2014-03-11 16:10:50 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet fund "function declaration" b
|
2017-02-11 08:01:38 -05:00
|
|
|
${1:void} ${2:function_name}($3);
|
2014-03-11 16:10:50 -04:00
|
|
|
endsnippet
|
|
|
|
|
2019-03-27 11:08:56 -04:00
|
|
|
global !p
|
|
|
|
def split_line(text):
|
|
|
|
import textwrap
|
|
|
|
lines = textwrap.wrap(text, 78 - 19)
|
|
|
|
output = list()
|
|
|
|
for line in lines:
|
|
|
|
output.append('*' + ' '*19 + line)
|
|
|
|
snip_line = snip.tabstops[4].end[0]
|
|
|
|
snip.buffer.append(output, snip_line + 1)
|
|
|
|
del snip.buffer[snip_line]
|
|
|
|
|
|
|
|
def get_args(arglist):
|
|
|
|
args = [arg.strip() for arg in arglist.split(',') if arg]
|
|
|
|
return args
|
|
|
|
endglobal
|
|
|
|
|
|
|
|
post_jump "if snip.tabstop == 0 : split_line(snip.tabstops[4].current_text)"
|
|
|
|
snippet head "File Header" b
|
|
|
|
/******************************************************************************
|
|
|
|
* File: `!p snip.rv = fn`
|
|
|
|
*
|
|
|
|
* Author: ${2}
|
|
|
|
* Created: `date +%m/%d/%y`
|
|
|
|
* Description: ${4:${VISUAL}}
|
|
|
|
*****************************************************************************/
|
|
|
|
${0}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
post_jump "if snip.tabstop == 0 : split_line(snip.tabstops[4].current_text)"
|
|
|
|
snippet func "Function Header"
|
|
|
|
/******************************************************************************
|
|
|
|
* Function: $1
|
|
|
|
* Description: ${4:${VISUAL}}
|
|
|
|
* Where:`!p
|
|
|
|
snip.rv = ""
|
|
|
|
snip >> 2
|
|
|
|
|
|
|
|
args = get_args(t[2])
|
|
|
|
if args:
|
|
|
|
for arg in args:
|
|
|
|
snip.rv += '\n' + '*' + ' '*19 + arg + ' - TODO'
|
|
|
|
snip << 2
|
|
|
|
`
|
|
|
|
* Return: $5
|
|
|
|
* Error: $6
|
|
|
|
*****************************************************************************/
|
|
|
|
${1}($2){
|
|
|
|
${0}
|
|
|
|
}
|
|
|
|
endsnippet
|
2012-08-16 23:41:25 -04:00
|
|
|
# vim:ft=snippets:
|