[TxMt] Re: Exploring Snippets

Allan Odgaard allan at macromates.com
Tue Feb 15 04:17:57 UTC 2005


On Feb 15, 2005, at 5:08, James Edward Gray II wrote:

>> $0 is the place where the cursor is placed after the snippet has been
>> run.
> Really?  I thought that was $1.  Then you can tab to $2, $3, etc.

By run I think he means “tabbed to the end”, i.e. gone through all the 
placeholders.

By default an implicit $0 is placed after your snippet, so e.g. if you 
write a snippet like: “foo $1 bar $2 fud” the caret starts at $1, you 
can tab to $2, but you can do a second tab to “leave” the snippet, and 
you end up just after “fud”, so in fact the snippet is: “foo $1 bar $2 
fud$3”.

Sometimes this is not desired, take this snippet:

\begin{$1}
$2
\end{$1}

Here we want to end between begin/end, but due to the implicit 
placeholder at the end of the snippet, a tab will take us outside this 
block. So instead we make it:

\begin{$1}
$0
\end{$1}

Then TextMate knows that you do not want the implicit tab position 
after the snippet, because you used $0.

Hope that clarifies it...




More information about the textmate mailing list