From 20c12eda3a79032e9fc24b3f8d43f11ca10d67c3 Mon Sep 17 00:00:00 2001 From: rudfol <33jhkim@gmail.com> Date: Sun, 29 Dec 2013 22:03:34 +0000 Subject: [PATCH 1/8] Added if snippets and update of coding style to most common --- UltiSnips/c.snippets | 47 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index e0cc7fd..2a346ce 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -18,12 +18,12 @@ ${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}} #endif endsnippet -snippet inc "#include local header (inc)" -#include "${1:`!p snip.rv = snip.basename + '.h'`}" +snippet #inc "#include <> (Inc)" +#include <${1:.h}> endsnippet -snippet Inc "#include <> (Inc)" -#include <${1:.h}> +snippet #Inc "#include local header (inc)" +#include "${1:`!p snip.rv = snip.basename + '.h'`}" endsnippet snippet mark "#pragma mark (mark)" @@ -44,15 +44,13 @@ int main(int argc, char *argv[]) endsnippet snippet for "for loop (for)" -for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) -{ +for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}){ ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet -snippet fori "for int loop (fori)" -for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) -{ +snippet fori "for int loop (with declaration)" +for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}){ ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet @@ -99,26 +97,35 @@ fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|% endsnippet snippet if "if .. (if)" -if (${1:/* condition */}) -{ - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +if (${1:/* condition */}){ + ${0:/* code */} } endsnippet snippet el "else .. (else)" else { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${0:/* code */} } endsnippet -snippet ife "if .. else (ife)" -if (${1:/* condition */}) -{ - ${2:/* code */} +snippet eli "else if .. (else if)" +else if (${1:/* condition */}) { + ${0:/* code */} } -else -{ - ${3:/* else */} +endsnippet + +snippet ifeli "if..else.if .. (ifeli)" +if (${1:/* condition */}) { + ${2:/* code */} +} else if (${3:/* condition */}) { + ${0:/* code */} +} + +snippet ife "if .. else (ife)" +if (${1:/* condition */}){ + ${2:/* code */} +} else{ + ${0:/* else */} } endsnippet From bc5e3bdb45dc3e9037edc0187ef355b125bbaded Mon Sep 17 00:00:00 2001 From: rudfol <33jhkim@gmail.com> Date: Tue, 31 Dec 2013 18:28:07 +0000 Subject: [PATCH 2/8] Added if snippets following general snippet style and triggers --- UltiSnips/c.snippets | 82 ++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index 2a346ce..7b40728 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -18,12 +18,12 @@ ${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}} #endif endsnippet -snippet #inc "#include <> (Inc)" -#include <${1:.h}> +snippet inc "#include local header (inc)" +#include "${1:`!p snip.rv = snip.basename + '.h'`}" endsnippet -snippet #Inc "#include local header (inc)" -#include "${1:`!p snip.rv = snip.basename + '.h'`}" +snippet Inc "#include <> (Inc)" +#include <${1:.h}> endsnippet snippet mark "#pragma mark (mark)" @@ -38,20 +38,22 @@ endsnippet snippet main "main() (main)" int main(int argc, char *argv[]) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} - return 0; + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + return 0; } endsnippet snippet for "for loop (for)" -for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}){ - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +{ + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet -snippet fori "for int loop (with declaration)" -for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}){ - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +snippet fori "for int loop (fori)" +for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +{ + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet @@ -62,10 +64,10 @@ 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() + 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: snip.rv = snip.c`} #define $1 @@ -82,13 +84,13 @@ endsnippet snippet wh "while loop" while(${1:/* condition */}) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet do "do...while loop (do)" do { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } while(${1:/* condition */}); endsnippet @@ -97,35 +99,47 @@ fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|% endsnippet snippet if "if .. (if)" -if (${1:/* condition */}){ - ${0:/* code */} +if (${1:/* condition */}) +{ + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet el "else .. (else)" else { - ${0:/* code */} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet -snippet eli "else if .. (else if)" +snippet eli "else if .. (eli)" else if (${1:/* condition */}) { - ${0:/* code */} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet -snippet ifeli "if..else.if .. (ifeli)" -if (${1:/* condition */}) { - ${2:/* code */} -} else if (${3:/* condition */}) { - ${0:/* code */} -} - snippet ife "if .. else (ife)" -if (${1:/* condition */}){ +if (${1:/* condition */}) +{ + ${2:/* code */} +} +else +{ + ${3:/* else */} +} +endsnippet + +snippet ifee "if .. else if .. else (ifee)" +if (${1:/* condition */}) +{ ${2:/* code */} -} else{ - ${0:/* else */} +} +else if (${3:/* condition */}) +{ + ${4:/* code */} +} +else +{ + ${5:/* code */} } endsnippet @@ -136,14 +150,14 @@ endsnippet snippet st "struct" struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} { - ${0:/* data */} + ${0:/* data */} }; endsnippet snippet fun "function" b ${1:void} ${2:function_name}(${3}) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet From 76327d17c641a7e065904cf862f8a2aadace1bdc Mon Sep 17 00:00:00 2001 From: rudfol <33jhkim@gmail.com> Date: Fri, 10 Jan 2014 21:23:46 +0000 Subject: [PATCH 3/8] Updated space problem- added 'if' --- UltiSnips/c.snippets | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index 7b40728..bace3a5 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -112,8 +112,20 @@ else { endsnippet snippet eli "else if .. (eli)" -else if (${1:/* condition */}) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +else if (${1:/* condition */}) +{ + ${2:/* else.i */} +} +endsnippet + +snippet elie "else if.. else (elie)" +else if (${1:/* condition */}) +{ + ${2:/* else.i */} +} +else +{ + ${3:/* else */} } endsnippet @@ -131,15 +143,15 @@ endsnippet snippet ifee "if .. else if .. else (ifee)" if (${1:/* condition */}) { - ${2:/* code */} + ${2:/* code */} } else if (${3:/* condition */}) { - ${4:/* code */} + ${4:/* else.i */} } else { - ${5:/* code */} + ${5:/* else */} } endsnippet From eb5f4946ad7e7cb87e2474ad3c400224070f1be0 Mon Sep 17 00:00:00 2001 From: rudfol <33jhkim@gmail.com> Date: Fri, 10 Jan 2014 21:49:13 +0000 Subject: [PATCH 4/8] Dynamic tab solve - added if statem' --- UltiSnips/c.snippets | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index bace3a5..0b474a9 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -38,22 +38,22 @@ endsnippet snippet main "main() (main)" int main(int argc, char *argv[]) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} - return 0; + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + return 0; } endsnippet snippet for "for loop (for)" for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet fori "for int loop (fori)" for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet @@ -64,10 +64,10 @@ 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() + 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: snip.rv = snip.c`} #define $1 @@ -84,13 +84,13 @@ endsnippet snippet wh "while loop" while(${1:/* condition */}) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet do "do...while loop (do)" do { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } while(${1:/* condition */}); endsnippet @@ -101,13 +101,13 @@ endsnippet snippet if "if .. (if)" if (${1:/* condition */}) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet el "else .. (else)" else { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet @@ -132,22 +132,22 @@ endsnippet snippet ife "if .. else (ife)" if (${1:/* condition */}) { - ${2:/* code */} + ${2:/* code */} } else { - ${3:/* else */} + ${3:/* else */} } endsnippet snippet ifee "if .. else if .. else (ifee)" if (${1:/* condition */}) { - ${2:/* code */} + ${2:/* code */} } else if (${3:/* condition */}) { - ${4:/* else.i */} + ${4:/* else.i */} } else { @@ -162,14 +162,14 @@ endsnippet snippet st "struct" struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} { - ${0:/* data */} + ${0:/* data */} }; endsnippet snippet fun "function" b ${1:void} ${2:function_name}(${3}) { - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet From 5b3aa799e4b4702c2a38a3975f41ac5cb6be5bd0 Mon Sep 17 00:00:00 2001 From: rudfol <33jhkim@gmail.com> Date: Sat, 11 Jan 2014 20:44:11 +0000 Subject: [PATCH 5/8] added 'if ..else' snippet --- UltiSnips/c.snippets | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index 0b474a9..f6a5ca5 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -112,23 +112,11 @@ else { endsnippet snippet eli "else if .. (eli)" -else if (${1:/* condition */}) -{ +else if (${1:/* condition */}) { ${2:/* else.i */} } endsnippet -snippet elie "else if.. else (elie)" -else if (${1:/* condition */}) -{ - ${2:/* else.i */} -} -else -{ - ${3:/* else */} -} -endsnippet - snippet ife "if .. else (ife)" if (${1:/* condition */}) { @@ -140,21 +128,6 @@ else } endsnippet -snippet ifee "if .. else if .. else (ifee)" -if (${1:/* condition */}) -{ - ${2:/* code */} -} -else if (${3:/* condition */}) -{ - ${4:/* else.i */} -} -else -{ - ${5:/* else */} -} -endsnippet - snippet printf "printf .. (printf)" printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} endsnippet From b0f5f6acf087f331234918ab9084e010aebeac70 Mon Sep 17 00:00:00 2001 From: rudfol <33jhkim@gmail.com> Date: Sat, 11 Jan 2014 20:44:11 +0000 Subject: [PATCH 6/8] added 'if else ..' snippet --- UltiSnips/c.snippets | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index 0b474a9..f6a5ca5 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -112,23 +112,11 @@ else { endsnippet snippet eli "else if .. (eli)" -else if (${1:/* condition */}) -{ +else if (${1:/* condition */}) { ${2:/* else.i */} } endsnippet -snippet elie "else if.. else (elie)" -else if (${1:/* condition */}) -{ - ${2:/* else.i */} -} -else -{ - ${3:/* else */} -} -endsnippet - snippet ife "if .. else (ife)" if (${1:/* condition */}) { @@ -140,21 +128,6 @@ else } endsnippet -snippet ifee "if .. else if .. else (ifee)" -if (${1:/* condition */}) -{ - ${2:/* code */} -} -else if (${3:/* condition */}) -{ - ${4:/* else.i */} -} -else -{ - ${5:/* else */} -} -endsnippet - snippet printf "printf .. (printf)" printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} endsnippet From 2b66c77695ff7f34d99bad6bb7adc78f81021d88 Mon Sep 17 00:00:00 2001 From: rudfol <33jhkim@gmail.com> Date: Thu, 16 Jan 2014 21:42:55 +0000 Subject: [PATCH 7/8] Added .. else if (eli) .. snippet --- UltiSnips/c.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index f6a5ca5..1b13928 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -112,8 +112,8 @@ else { endsnippet snippet eli "else if .. (eli)" + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} else if (${1:/* condition */}) { - ${2:/* else.i */} } endsnippet From 3426be5654e93e24095592f52820d7918fd1a691 Mon Sep 17 00:00:00 2001 From: rudfol <33jhkim@gmail.com> Date: Thu, 16 Jan 2014 21:44:28 +0000 Subject: [PATCH 8/8] added .. else if (eli) .. snippet --- UltiSnips/c.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index 1b13928..9fd1615 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -112,8 +112,8 @@ else { endsnippet snippet eli "else if .. (eli)" - ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} else if (${1:/* condition */}) { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet