Is it possible to have a repeating tabstop in a snippet?
for example it would be great to have a snippet to insert a html option list:
<select> <option value="$1">$2</option> </select>
You tab to $1, fill in the value, tab to $2, fill in the content, then when you press tab again, it inserts another option:
<select> <option value="1">Cherry</option> <option value="$3">$4</option> </select>
And carries on doing so for an arbitrarily long time.
If it's possible to do this I'd be very grateful.
Thanks
Ed
Hi Ed,
Actually that's pretty easy to do.
Create your first snippet like so, assigning the tab trigger to whatever phrase you like:
<select> <option value="$1">$2</option> opt$0 </select>
Then create a second snippet like this:
<option value="$1">$2</option> opt$0
I have assigned this snippet to a tab trigger of opt. If you call yours something different, you need to change the opt reference in the two snippets. When you use the first snippet, you'll tab through the two values, then tab to the end of "opt", press tab again, which triggers the opt tab trigger. The same will happen in the second snippet. The only caveat to this is that when you've added all your options, you'll have to manually delete out the last opt tab trigger word. I don't think there's any way around this but is not a major issue. I'll happily be told if there's a better way!
Hope that helps.
Andy
On Oct 23, 2006, at 12:22 PM, Andrew Henson wrote:
<select> <option value="$1">$2</option> opt$0 </select>
Then create a second snippet like this:
<option value="$1">$2</option> opt$0
The only caveat to this is that when you've added all your options, you'll have to manually delete out the last opt tab trigger word. I don't think there's any way around this but is not a major issue. I'll happily be told if there's a better way!
If you change both of the 'opt$0' lines to:
${3:opt}$0
You add two tab keystrokes to continuation (easy repetition) and gain the ability to simply delete the already selected 'opt' after you've added your final option.
- Rod
Okay, tell me if this is stupid, but is there any reason you couldn't make </select> the tab trigger? Then you'd be able to add on to the end of any select list and not have to delete anything off the end... I'm trying it out with unordered lists right now and I can't find any problems, but I tend to be short sighted on these things.
Brett
On Oct 23, 2006, at 3:05 PM, Rod Knowlton wrote:
On Oct 23, 2006, at 12:22 PM, Andrew Henson wrote:
<select> <option value="$1">$2</option> opt$0 </select>
Then create a second snippet like this:
<option value="$1">$2</option> opt$0
The only caveat to this is that when you've added all your options, you'll have to manually delete out the last opt tab trigger word. I don't think there's any way around this but is not a major issue. I'll happily be told if there's a better way!
If you change both of the 'opt$0' lines to:
${3:opt}$0
You add two tab keystrokes to continuation (easy repetition) and gain the ability to simply delete the already selected 'opt' after you've added your final option.
- Rod
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................
On 23/10/06, Andrew Henson elaptics@googlemail.com wrote:
Hi Ed,
Actually that's pretty easy to do.
Create your first snippet like so, assigning the tab trigger to whatever phrase you like:
<select> <option value="$1">$2</option> opt$0 </select>
Then create a second snippet like this:
<option value="$1">$2</option> opt$0
I have assigned this snippet to a tab trigger of opt. If you call yours something different, you need to change the opt reference in the two snippets. When you use the first snippet, you'll tab through the two values, then tab to the end of "opt", press tab again, which triggers the opt tab trigger. The same will happen in the second snippet. The only caveat to this is that when you've added all your options, you'll have to manually delete out the last opt tab trigger word. I don't think there's any way around this but is not a major issue. I'll happily be told if there's a better way!
That's genius! One of those things that's so simple, you know you should have been able to work out by yourself, but it always seems I don't.
Thanks for that.
Ed