snippet doc "Documentation" b /** * ${1:description} * * @param ${2:pname} ${3:pdesc} * @return ${4:return desc} */ endsnippet snippet desc "Description Comment" b /** * ${1:Description} * * @author ${2:`git config --get user.name`} <${3:`git config --get user.email`}> */ $0 endsnippet snippet code " tag" w ${1}${0} endsnippet snippet for "for loop (for)" 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}) { ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet enum "Enumeration" enum ${1:name} { $0 }; 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() else: snip.rv = snip.c`} #define $1 ${0} #endif /* end of include guard: $1 */ endsnippet snippet td "Typedef" typedef ${1:int} ${2:MyCustomType}; endsnippet snippet wh "while loop" while(${1:/* condition */}) { ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet do "do...while loop (do)" do { ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } while(${1:/* condition */}); endsnippet snippet fprintf "fprintf ..." fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/} endsnippet snippet if "if .. (if)" if (${1:/* condition */}) { ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet el "else .. (else)" else { ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet eli "else if .. (eli)" else if (${1:/* condition */}) { ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet ife "if .. else (ife)" if (${1:/* condition */}) { ${2:/* code */} } else { ${3:/* else */} } endsnippet snippet printf "printf .. (printf)" printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} endsnippet snippet st "struct" struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} { ${0:/* data */} }; endsnippet snippet fun "function" b ${1:void} ${2:function_name}(${3}) { ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet fund "function declaration" b ${1:void} ${2:function_name}(${3}); endsnippet snippet tmibsd "TMI Modified BSD License for C" b /* Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")`, ${1:Titanium Mirror, Inc}. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - Neither the name of $1 nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ $0 endsnippet snippet tmiprop "TMI Proprietary License for C" b /* Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")`, ${1:Titanium Mirror, Inc}. * All Rights Reserved. * * This document is the proprietary and confidential property of * $1. All use, distribution, reproduction or re-distribution * is disallowed without the prior express written consent of * $1. */ $0 endsnippet # vim:ft=snippets: