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:\);)/} fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet endsnippet
snippet if "if .. (if)"
if (${1:/* condition */}) {
${VISUAL}${0}
}
endsnippet
snippet el "else .. (else)"
else {
${VISUAL}${0}
}
endsnippet
snippet eli "else if .. (eli)" snippet eli "else if .. (eli)"
else if (${1:/* condition */}) { else if (${1:/* condition */}) {
${VISUAL}${0} ${VISUAL}${0}
} }
endsnippet endsnippet
snippet ife "if .. else (ife)"
if (${1:/* condition */}) {
${2}
} else {
${3:/* else */}
}
endsnippet
snippet printf "printf .. (printf)" snippet printf "printf .. (printf)"
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet endsnippet

View File

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