diff --git a/snippets/c.snippets b/snippets/c.snippets index e1c4f050..8890f1a7 100644 --- a/snippets/c.snippets +++ b/snippets/c.snippets @@ -35,42 +35,55 @@ snippet #if # Header Include-Guard snippet once #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} - #define $1 + #ifdef __cplusplus + extern "C" + { + #endif /* end of __cplusplus */ + ${2} + #ifdef __cplusplus + } + #endif /* end of __cplusplus */ #endif /* end of include guard: $1 */ # If Condition snippet if - if (${1:/* condition */}) { + if (${1:/* condition */}) + { ${2:/* code */} } snippet el - else { + else + { ${1} } -# Ternary conditional +# Tertiary conditional snippet t ${1:/* condition */} ? ${2:a} : ${3:b} # Do While Loop snippet do - do { + do + { ${2:/* code */} } while (${1:/* condition */}); # While Loop snippet wh - while (${1:/* condition */}) { + while (${1:/* condition */}) + { ${2:/* code */} } # For Loop snippet for - for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { + for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) + { ${4:/* code */} } # Custom For Loop snippet forr - for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { + for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) + { ${5:/* code */} } # Function @@ -87,17 +100,20 @@ snippet td typedef ${1:int} ${2:MyCustomType};${3} # Struct snippet st - struct ${1:`Filename('$1_t', 'name')`} { + struct ${1:`Filename('$1_t', 'name')`} + { ${2:/* data */} }${3: /* optional variable list */};${4} # Typedef struct snippet tds - typedef struct ${2:_$1 }{ + typedef struct ${2:_$1 } + { ${3:/* data */} } ${1:`Filename('$1_t', 'name')`}; # Typdef enum snippet tde - typedef enum { + typedef enum ${3:_$2 } + { ${1:/* data */} } ${2:foo}; # printf