I want to produce [origin [pt x]]; using a snippet called msg (short for message) that looks like this [${1:Receiver} ${2:message}]
When I write msg and hit tab I am presented with [Receiver message] where Receiver is highlighted. I write origin and hit tab. Now I get [origin message] and message is highlighted.
I write msg again and hit tab.
To my surprise I get [origin msg] with tha caret after the last bracket .
So it seems that TM is giving priority to the outer snippet??? But I think that two other alternatives might be better
Alternative 1: Forget all tab stops for the first snippet when an inner snippet is activated.
Another alternative is
Alternative 2: When hitting tab give priority to the inner snippet first and when it is finished then give focus to the outer snippet and let it do its thing.
If I am wrong in my thinking tell me why. If I am right maybe it is some programming difficulty with nested snippets that prevents the desired behavior.
Thanks Bob
On Aug 10, 2007, at 2:00 PM, Cocoa Bob wrote:
I want to produce [origin [pt x]]; using a snippet called msg (short for message) that looks like this [${1:Receiver} ${2:message}]
[snip]
If I am wrong in my thinking tell me why. If I am right maybe it is some programming difficulty with nested snippets that prevents the desired behavior.
The reason things behave in a way that you did not expect is simply that nested snippets are not a supported feature of TM yet, though one often requested. (You can search through the ticket system, and file a new ticket if it is not already there: http://macromates.com/ ticket/ ). Hence atm, pressing tab within a snippet just moves forward among the tab stops. There are two ways to solve the problem in your case:
1. Use a key equivalent instead of a tab trigger. Say for instance that you have set the key equivalent for your command to F8. Then using that instead of "msg+tab" would give you a more desired behavior (essentially, the old snippet is forgotten the moment the new one is triggered). 2. Set the snippet to be: [${1:Receiver} ${0:message}]. Then "msg +tab" will work as expected on the message side, since you have ended the snippet at the 0th tab stop. On the other hand, you will still have problems if you tried to call "msg+tab" on the Receiver side (This would be a problem in the first case as well, though of a slightly different nature).
Thanks Bob
Haris Skiadas Department of Mathematics and Computer Science Hanover College