220 lines
5.3 KiB
JSON
220 lines
5.3 KiB
JSON
{
|
|
"for": {
|
|
"prefix": "for",
|
|
"body": [
|
|
"for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:length}; $2++) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "Code snippet for 'for' loop"
|
|
},
|
|
"*": {
|
|
"prefix": "*",
|
|
"body": ["/* $0 */"],
|
|
"description": "Block comment"
|
|
},
|
|
"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"
|
|
},
|
|
"mod": {
|
|
"prefix": "MOD",
|
|
"body": ["#define MOD(N,M)\t((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))"],
|
|
"description": "mod of N,M"
|
|
},
|
|
"between": {
|
|
"prefix": "between",
|
|
"body": ["#define BETWEEN(x, a, b)\t((a) <= (x) && (x) <= (b))"],
|
|
"description": "x is between a, b"
|
|
},
|
|
"sze" : {
|
|
"prefix": "sze",
|
|
"body": ["#define SIZE(x) sizeof(x)/sizeof(x[0])","$0"],
|
|
"description": "Array size macro"
|
|
},
|
|
"do": {
|
|
"prefix": "do",
|
|
"body": ["do", "{", "\t$1", "} while($2);"],
|
|
"description": "Code snippet for do...while loop"
|
|
},
|
|
"while": {
|
|
"prefix": "while",
|
|
"body": ["while ($1) {", "\t$2", "}"],
|
|
"description": ""
|
|
},
|
|
"foreach": {
|
|
"prefix": "foreach",
|
|
"body": ["for (${1:auto} ${2:var} : ${3:collection_to_loop}) {", "\t$0", "}"],
|
|
"description": "Code snippet for range-based for loop (c++11) statement"
|
|
},
|
|
"enum": {
|
|
"prefix": "enum",
|
|
"body": ["enum ${1:MyEnum} {", "\t$0", "};"],
|
|
"description": "Code snippet for enum"
|
|
},
|
|
"enum class": {
|
|
"prefix": "enum class",
|
|
"body": ["enum class ${1:MyClass} {$0};"],
|
|
"description": "Code snippet for enum class (c++11)"
|
|
},
|
|
"class": {
|
|
"prefix": "class",
|
|
"body": [
|
|
"class ${1:MyClass}",
|
|
"{",
|
|
"public:",
|
|
"\t$1();",
|
|
"\t$1($1 &&) = default;",
|
|
"\t$1(const $1 &) = default;",
|
|
"\t$1 &operator=($1 &&) = default;",
|
|
"\t$1 &operator=(const $1 &) = default;",
|
|
"\t~$1();",
|
|
"",
|
|
"private:",
|
|
"\t$2",
|
|
"};",
|
|
"",
|
|
"$1::$1()",
|
|
"{",
|
|
"}",
|
|
"",
|
|
"$1::~$1()",
|
|
"{",
|
|
"}"
|
|
],
|
|
"description": "Code snippet for class"
|
|
},
|
|
"classi": {
|
|
"prefix": "classi",
|
|
"body": [
|
|
"class ${1:MyClass}",
|
|
"{",
|
|
"public:",
|
|
"\t$1() = default;",
|
|
"\t$1($1 &&) = default;",
|
|
"\t$1(const $1 &) = default;",
|
|
"\t$1 &operator=($1 &&) = default;",
|
|
"\t$1 &operator=(const $1 &) = default;",
|
|
"\t~$1() = default;",
|
|
"",
|
|
"private:",
|
|
"\t$2",
|
|
"};"
|
|
],
|
|
"description": "Code snippet for class with inline constructor/destructor"
|
|
},
|
|
"interface": {
|
|
"prefix": "interface",
|
|
"body": ["__interface I${1:Interface}", "{", "\t$0", "};"],
|
|
"description": "Code snippet for interface (Visual C++)"
|
|
},
|
|
"namespace": {
|
|
"prefix": "namespace",
|
|
"body": ["namespace ${1:MyNamespace}", "{", "\t$0", "}"]
|
|
},
|
|
"#ifdef": {
|
|
"prefix": "#ifdef",
|
|
"body": ["#ifdef ${1:DEBUG}", "$0", "#endif // ${DEBUG}"],
|
|
"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"
|
|
},
|
|
"switch": {
|
|
"prefix": "switch",
|
|
"body": ["switch (${1:switch_on}) {", "\tdefault:", "\t\t$0", "\t\tbreak;", "}"],
|
|
"description": "Code snippet for switch statement"
|
|
},
|
|
"try": {
|
|
"prefix": "try",
|
|
"body": [
|
|
"try {",
|
|
"\t",
|
|
"}",
|
|
"catch (const std::exception&)",
|
|
"{",
|
|
"\t$1",
|
|
"}"
|
|
],
|
|
"description": "Code snippet for try catch"
|
|
},
|
|
"union": {
|
|
"prefix": "union",
|
|
"body": ["union ${1:MyUnion}", "{", "\t$0", "};"],
|
|
"description": "Code snippet for union"
|
|
},
|
|
"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"
|
|
},
|
|
"#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"
|
|
}
|
|
}
|