C: Remove some duplication

This commit is contained in:
Louis Pilfold 2015-04-26 19:44:26 +01:00
parent 730b2f8141
commit 73f22df5ca
2 changed files with 11 additions and 25 deletions

View File

@ -97,32 +97,12 @@ snippet fprintf "fprintf ..."
fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet
snippet if "if .. (if)"
if (${1:/* condition */}) {
${VISUAL}${0}
}
endsnippet
snippet el "else .. (else)"
else {
${VISUAL}${0}
}
endsnippet
snippet eli "else if .. (eli)"
else if (${1:/* condition */}) {
${VISUAL}${0}
}
endsnippet
snippet ife "if .. else (ife)"
if (${1:/* condition */}) {
${2}
} else {
${3:/* else */}
}
endsnippet
snippet printf "printf .. (printf)"
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet

View File

@ -52,22 +52,28 @@ snippet once
## Control Statements
# if
snippet if
if (${1:/* condition */}) {
if (${1:true}) {
${0}
}
snippet ife
if (${1:true}) {
${2}
} else {
${0}
}
# else
snippet el
else {
${1}
${0}
}
# else if
snippet elif
else if (${1:/* condition */}) {
${2}
else if (${1:true}) {
${0}
}
# ifi
snippet ifi
if (${1:/* condition */}) ${2};
if (${1:true}) ${0};
# ternary
snippet t
${1:/* condition */} ? ${2:a} : ${3:b}