[TextMate] Tab in snippets

Benny Kjær Nielsen benny at diku.dk
Thu Oct 7 04:42:57 UTC 2004


On Wed, 6 Oct 2004, Sune Foldager wrote:

> On 6/10-2004, at 20:21, Joost Schuttelaar wrote:
>
> > Small thingie: I think it would be very convenient if after entering
> > all the parameters in the snippet, the tab key would place the cursor
> > at the end of the snippet.
>
> I agree, although this is possible of course in the current version
> like this:
> <img src="$1" />$2
>
> Or similar. I believe $0 can also be used for that purpose, regardless
> of the number of tab stops. I sort of think that this should not be
> neccesary and it should always end up after the snippet body no matter
> what... I can't imagine any situation where you _don't_ want that.. ?

Well, I needed it for a snippet I created for latex to make begin/end
constructions such as:

\begin{itemize}
\end{itemize}

Here you want the cursor to end up on a blank line between the two lines
of the snippet. Note a really nice TM feature here. If you specify the
same placeholder twice ($1 below) then it is filled out simultaneously
when using the snippet (this is a documented feature). Really cool ;-)

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

Since it might be a bit annoying to always having to define $0 for
snippets simply needing the cursor at the end of the snippet this could
simply be interpreted as the default if no $0 placeholder is specified.

-- 
Benny



More information about the textmate mailing list