Skip to content

Instantly share code, notes, and snippets.

@Agyar
Last active December 23, 2015 09:09
Show Gist options
  • Save Agyar/6612652 to your computer and use it in GitHub Desktop.
Save Agyar/6612652 to your computer and use it in GitHub Desktop.
C/C++ snippets for Ultisnip vim plugin
snippet ifc "#if #endif" !b
#if ${1:0}
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
#endif
endsnippet
snippet ts "struct"
typedef struct
{
${0:/* data */}
} ${1:`!p snip.rv = (snip.basename or "name") + "_t"`};
endsnippet
snippet ifd "#ifdef ... #endif"
#ifdef ${1:FOO}
${2}
#endif // $1
${3}
endsnippet
snippet . "tab"
[${1}]${2}
endsnippet
snippet for "for loop (for)"
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
} // end of loop on $1
endsnippet
snippet fori "for int loop (fori)"
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
} // end of loop on $1
endsnippet
snippet op
#pragma omp parallel
endsnippet
snippet of
#pragma omp for ${1:} schedule(${2:dynamic},${3:var})
endsnippet
snippet opf
#pragma omp parallel for ${1:}
endsnippet
snippet tecm "template class method"
template <class ${1:T}> ${2:void} ${3:className}<$1>
::${4:methodName}(${5:})
{
${6:// insert code}
}
endsnippet
snippet tef "template function"
template <class ${1:T}>
${2:void} ${3:methodName}(${4:})
{
${5:// insert code}
}
endsnippet
snippet th
this->${1:dodelidoo}
endsnippet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment