1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
{
"for": {
"prefix": "for",
"body": [
"for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:length}; $2++) {",
"\t$0",
"}"
],
"description": "Code snippet for 'for' loop"
},
"forr": {
"prefix": "forr",
"body": [
"for (${1:size_t} ${2:i} = ${3:length} - 1; $2 >= ${4:0}; $2--) {",
"\t$0",
"}"
],
"description": "Code snippet for reverse 'for' loop"
},
"while": {
"prefix": "while",
"body": ["while ($1) {", "\t$0", "}"],
"description": ""
},
"if": {
"prefix": "if",
"body": ["if ($1) {", "\t$0", "}"],
"description": "Code snippet for if statement"
},
"else": {
"prefix": "else",
"body": ["else {", "\t$0", "}"],
"description": "Code snippet for else statement"
},
"else if": {
"prefix": "else if",
"body": ["else if ($1) {", "\t$0", "}"],
"description": "Code snippet for else-if statement"
},
"enum": {
"prefix": "enum",
"body": ["enum ${1:MyEnum} {", "\t$0", "};"],
"description": "Code snippet for enum"
},
"#ifdef": {
"prefix": "#ifdef",
"body": ["#ifdef ${1:DEBUG}", "$0", "#endif /* $1 */"],
"description": "Code snippet for #ifdef"
},
"#ifndef": {
"prefix": "#ifndef",
"body": ["#ifndef ${1:DEBUG}", "$0", "#endif /* !$1 */"],
"description": "Code snippet for #ifndef"
},
"#if": {
"prefix": "#if",
"body": ["#if ${1:0}", "$0", "#endif /* $1 */"],
"description": "Code snippet for #if"
},
"struct": {
"prefix": "struct",
"body": ["struct ${1:MyStruct} {", "\t$0", "};"],
"description": "Code snippet for struct"
},
"typedef struct": {
"prefix": "structt",
"body": ["typedef struct {", "\t$0", "} ${1:MyStruct};"],
"description": "Code snippet to define a type with struct"
},
"switch": {
"prefix": "switch",
"body": ["switch (${1:switch_on}) {", "\tdefault:", "\t\t$0", "\t\tbreak;", "}"],
"description": "Code snippet for switch statement"
},
"case": {
"prefix": "case",
"body": ["case $1:", "\t$0", "\tbreak;"],
"description": "Code snippet for case branch"
},
"union": {
"prefix": "union",
"body": ["union ${1:MyUnion} {", "\t$0", "};"],
"description": "Code snippet for union"
},
"#inc": {
"prefix": "#inc",
"body": ["#include \"$0\""],
"description": "Code snippet for #include \" \""
},
"#inc<": {
"prefix": "#inc<",
"body": ["#include <$0>"],
"description": "Code snippet for #include < >"
},
"#def": {
"prefix": "def",
"body": ["#define $0"],
"description": "Code snippet for #define \" \""
},
"Main function template": {
"prefix": "main",
"body": [
"int main (int argc, char *argv[])",
"{",
"\t$0",
"\treturn 0;",
"}"
],
"description": "A standard main function for a C program"
},
"Standard Starter Template": {
"prefix": "sst",
"body": [
"#include <stdio.h>",
"",
"int main (int argc, char *argv[])",
"{",
"\t$0",
"\treturn 0;",
"}"
],
"description": "A standard starter template for a C program"
},
"Stdlib Variant Starter Template": {
"prefix": "libsst",
"body": [
"#include <stdio.h>",
"#include <stdlib.h>",
"",
"int main (int argc, char *argv[])",
"{",
"\t$0",
"\treturn 0;",
"}"
],
"description": "A standard starter template for a C program with stdlib included"
},
"Do...while loop": {
"prefix": "do",
"body": ["do {", "\t$1", "} while($2);"],
"description": "Creates a do...while loop"
},
"Create linked list": {
"prefix": "clist",
"body": [
"typedef struct _node * Link;",
"typedef struct _node node;",
"struct _node {",
"\tint value;",
"\tLink next;",
"};"
],
"description": "Creates a linked list template"
},
"Create a function": {
"prefix": "func",
"body": ["${2:void} ${1:func}(${4:void})", "{", "\t$3", "}"],
"description": "Creates a function"
},
"Create int function": {
"prefix": "intfunc",
"body": ["int $1 ()", "{", "\tint $2 = $3;$4", "\treturn $2;", "}"],
"description": "Creates a function that returns the int type"
},
"Create float function": {
"prefix": "flfunc",
"body": ["float $1 ()", "{", "\tfloat $2 = $3;$4", "\treturn $2;", "}"],
"description": "Creates a function that returns the float type"
},
"Create double function": {
"prefix": "doubfunc",
"body": ["double $1 ()", "{", "\tdouble $2 = $3;$4", "\treturn $2;", "}"],
"description": "Creates a function that returns the double type"
},
"Create string function": {
"prefix": "strfunc",
"body": ["char[] $1 ()", "{", "\tchar[] $2 = {$3};$4", "\treturn $2;", "}"],
"description": "Creates a function that returns the char array type"
},
"Create long function": {
"prefix": "longfunc",
"body": ["long $1 ()", "{", "\tlong $2 = $3;$4", "\treturn $3;", "}"],
"description": "Creates a function that returns the long type"
},
"Print variable of type float (2 decimal places)": {
"prefix": "pflo",
"body": ["printf(\"$0 :>> %.2f\\n\", $0);"],
"description": "Calls printf() to log value of variable of type float rounded to 2 decimal places"
},
"Print variable of type integer": {
"prefix": "pint",
"body": ["printf(\"$0 :>> %d\\n\", $0);"],
"description": "Calls printf() to log value of variable of type signed integer"
},
"Print variable of type char": {
"prefix": "pcha",
"body": ["printf(\"$0 :>> %c\\n\", $0);"],
"description": "Calls printf() to log value of variable of type char"
},
"Print variable of type pointer": {
"prefix": "ppoint",
"body": ["printf(\"$0 :>> %p\\n\", (void *) $0);"],
"description": "Calls printf() to log value of variable of type pointer"
},
"Print variable of type size_t": {
"prefix": "psiz",
"body": ["printf(\"$0 :>> %zu\\n\", $0);"],
"description": "Calls printf() to log value of variable of type size_t"
},
"printf": {
"prefix": "printf",
"body": ["printf(\"$1\\n\"$0);"],
"description": "Generic printf() snippet"
},
"sprintf": {
"prefix": "sprintf",
"body": ["sprintf($1, \"$2\\n\"$0);"],
"description": "Generic sprintf() snippet"
},
"fprintf": {
"prefix": "fprintf",
"body": ["fprintf(${1:stderr}, \"$2\\n\"$0);"],
"description": "Generic fprintf() snippet"
},
"scanf": {
"prefix": "scanf",
"body": ["scanf(\"$1\"$0);"],
"description": "Generic scanf() snippet"
},
"sscanf": {
"prefix": "sscanf",
"body": ["sscanf($1, \"$2\"$0);"],
"description": "Generic sscanf() snippet"
},
"fscanf": {
"prefix": "fscanf",
"body": ["fscanf($1, \"$2\"$0);"],
"description": "Generic fscanf() snippet"
},
"Allocate memory using malloc": {
"prefix": "mal",
"body": [
"${1:int} *${2:v} = malloc(${3:1} * sizeof($1));",
"",
"if (!$2) {",
"\tfprintf(stderr, \"Memory allocation failed!\\n\");",
"\t$4;",
"}",
"$0",
"free($2);"
],
"description": "Allocates memory to a pointer variable using malloc(), then deallocates using free()."
},
"Allocate memory using calloc": {
"prefix": "cal",
"body": [
"${1:int} *${2:v} = calloc(${3:1}, sizeof($1));",
"",
"if (!$2) {",
"\tfprintf(stderr, \"Memory allocation failed!\\n\");",
"\t$4;",
"}",
"$0",
"free($2);"
],
"description": "Allocates memory to a pointer variable using calloc(), then deallocates using free()."
}
}
|