my yasnippet version = 0.5.10
i tend to use unsigned int in my for loops as opposed to ints so a typical for loop in my c++ code looks like the following
for(unsigned int row = 0 ; row < numRows ; ++row)
{
}
on the other hand the default for snippet in yasnippet looks like this
for(int i = 0 ; i < N ; ++i)
{
blah
}
the TAB key takes on to the points shown in red so that one can start typing whatever they want at those points. there is no point in stopping at `i’ of int, I want to have the “unsigned int” or “int” part in place and want to type in a meaningful variable name so i would prefer a starting position as in `i’ just before the `=’ sign. Also if that name has been changed from the default value ( `i’ in this case ) to something else then i want the change to be reflected automatically in the condition statement as well as in the increment statement
for(unsigned int row = 0 ; row < numRows ; ++row)
{
blah
}
so this is how i rewrote the template file for “for”
for(unsigned int $1 = 0; $1 < $2; ++$1)
{
$0
}
Notice that $1 is now present in the condition statement as well as the increment statement so I don’t have to write them twice if I change the default value. ( though i don’t use a default value in the above example). Much happier man now 😀
this was a motivation to finally take the plunge.
You might want to try (and test) the new beta release 0.6.0b which aims to bring the templating system closer to Textmate. See http://yasnippet.googlecode.com/svn/trunk/doc/changelog.html
thank you for the heads up 🙂