1
0
mirror of https://github.com/gryf/snipmate.vim.git synced 2025-12-19 20:38:05 +01:00

updated C snippets

This commit is contained in:
Michael Sanders
2009-07-13 11:21:33 -04:00
parent 9e11b093d4
commit ddd6b8f156

View File

@@ -1,6 +1,6 @@
# main() # main()
snippet main snippet main
int main(int argc, char const* argv[]) int main(int argc, const char *argv[])
{ {
${1} ${1}
return 0; return 0;
@@ -18,16 +18,24 @@ snippet Def
#endif${3} #endif${3}
snippet def snippet def
#define #define
snippet ifdef
#ifdef ${1:FOO}
${2:#define }
#endif
snippet #if
#if ${1:FOO}
${2}
#endif
# Header Include-Guard # Header Include-Guard
# (the randomizer code is taken directly from TextMate; it could probably be # (the randomizer code is taken directly from TextMate; it could probably be
# cleaner, I don't know how to do it in vim script) # cleaner, I don't know how to do it in vim script)
snippet once snippet once
#ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`} #ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`}
#define $1 #define $1
${2} ${2}
#endif /* end of include guard: $1 */ #endif /* end of include guard: $1 */
# If Condition # If Condition
snippet if snippet if
@@ -67,9 +75,12 @@ snippet fun
{ {
${4:/* code */} ${4:/* code */}
} }
# Function Declaration
snippet fund
${1:void} ${2:function_name}(${3});${4}
# Typedef # Typedef
snippet td snippet td
typedef ${1:int} ${2:MyCustomType}; typedef ${1:int} ${2:MyCustomType};${3}
# Struct # Struct
snippet st snippet st
struct ${1:`Filename('$1_t', 'name')`} { struct ${1:`Filename('$1_t', 'name')`} {
@@ -77,9 +88,14 @@ snippet st
}${3: /* optional variable list */};${4} }${3: /* optional variable list */};${4}
# Typedef struct # Typedef struct
snippet tds snippet tds
typedef struct ${2:$1 }{ typedef struct ${2:_$1 }{
${3:/* data */} ${3:/* data */}
} ${1:`Filename('$1_t', 'name')`}; } ${1:`Filename('$1_t', 'name')`};
# Typdef enum
snippet tde
typedef enum {
${1:/* data */}
} ${2:foo};
# printf # printf
# unfortunately version this isn't as nice as TextMates's, given the lack of a # unfortunately version this isn't as nice as TextMates's, given the lack of a
# dynamic `...` # dynamic `...`
@@ -88,3 +104,7 @@ snippet pr
# fprintf (again, this isn't as nice as TextMate's version, but it works) # fprintf (again, this isn't as nice as TextMate's version, but it works)
snippet fpr snippet fpr
fprintf(${1:stderr}, "${2:%s}\n"${3});${4} fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
snippet .
[${1}]${2}
snippet un
unsigned