[c/cpp] Added postfix tab stop to most snippets

This allows for people to quickly tab to the end of the snippet and
continue writing code without having to exit insert mode.
This commit is contained in:
Aaron Broder 2012-08-28 11:22:24 -07:00
parent 5ea5d2893a
commit 67c276b85d
2 changed files with 19 additions and 19 deletions

View File

@ -27,11 +27,11 @@ snippet def
snippet ifdef snippet ifdef
#ifdef ${1:FOO} #ifdef ${1:FOO}
${2:#define } ${2:#define }
#endif #endif${3}
snippet #if snippet #if
#if ${1:FOO} #if ${1:FOO}
${2} ${2}
#endif #endif${3}
# Header Include-Guard # Header Include-Guard
snippet once snippet once
#ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`}
@ -45,15 +45,15 @@ snippet once
snippet if snippet if
if (${1:/* condition */}) { if (${1:/* condition */}) {
${2:/* code */} ${2:/* code */}
} }${3}
snippet el snippet el
else { else {
${1} ${1}
} }${2}
snippet elif snippet elif
else if (${1:/* condition */}) { else if (${1:/* condition */}) {
${2:/* code */} ${2:/* code */}
} }${3}
# Ternary conditional # Ternary conditional
snippet t snippet t
${1:/* condition */} ? ${2:a} : ${3:b} ${1:/* condition */} ? ${2:a} : ${3:b}
@ -61,28 +61,28 @@ snippet t
snippet do snippet do
do { do {
${2:/* code */} ${2:/* code */}
} while (${1:/* condition */}); } while (${1:/* condition */});${3}
# While Loop # While Loop
snippet wh snippet wh
while (${1:/* condition */}) { while (${1:/* condition */}) {
${2:/* code */} ${2:/* code */}
} }${3}
# For Loop # For Loop
snippet for snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */} ${4:/* code */}
} }${5}
# Custom For Loop # Custom For Loop
snippet forr snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5:/* code */} ${5:/* code */}
} }${6}
# Function # Function
snippet fun snippet fun
${1:void} ${2:function_name}(${3}) ${1:void} ${2:function_name}(${3})
{ {
${4:/* code */} ${4:/* code */}
} }${5}
# Function Declaration # Function Declaration
snippet fund snippet fund
${1:void} ${2:function_name}(${3});${4} ${1:void} ${2:function_name}(${3});${4}
@ -98,12 +98,12 @@ snippet st
snippet tds snippet tds
typedef struct ${2:_$1 }{ typedef struct ${2:_$1 }{
${3:/* data */} ${3:/* data */}
} ${1:`Filename('$1_t', 'name')`}; } ${1:`Filename('$1_t', 'name')`};${4}
# Typdef enum # Typdef enum
snippet tde snippet tde
typedef enum { typedef enum {
${1:/* data */} ${1:/* data */}
} ${2:foo}; } ${2:foo};${3}
# printf # printf
# unfortunately version this isn't as nice as TextMates's, given the lack of a # unfortunately version this isn't as nice as TextMates's, given the lack of a
# dynamic `...` # dynamic `...`

View File

@ -80,7 +80,7 @@ snippet cl
# member function implementation # member function implementation
snippet mfun snippet mfun
${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) { ${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
${5:return}; ${5:/* code */}
} }
# namespace # namespace
snippet ns snippet ns
@ -91,10 +91,10 @@ snippet ns
## Input/Output ## Input/Output
# std::cout # std::cout
snippet cout snippet cout
std::cout << ${1} << std::endl; std::cout << ${1} << std::endl;${2}
# std::cin # std::cin
snippet cin snippet cin
std::cin >> ${1}; std::cin >> ${1};${2}
# read file into vector # read file into vector
snippet readfile snippet readfile
std::vector<char> v; std::vector<char> v;
@ -111,22 +111,22 @@ snippet readfile
snippet fori snippet fori
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */} ${4:/* code */}
} }${5}
# foreach # foreach
snippet fore snippet fore
for (${1:auto} ${2:i} : ${3:container}) { for (${1:auto} ${2:i} : ${3:container}) {
${4:/* code */} ${4:/* code */}
} }${5}
# iterator # iterator
snippet iter snippet iter
for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) { for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {
${6} ${6}
} }${7}
# auto iterator # auto iterator
snippet itera snippet itera
for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) { for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) {
${2:std::cout << *$1 << std::endl;} ${2:std::cout << *$1 << std::endl;}
} }${3}