[TxMt] html snippets, why the selected text part?

Jeroen van der Ham jeroen at je-ju.net
Sat May 21 21:44:54 UTC 2005


On 21-05-2005 22:28, Charilaos Skiadas wrote:
> In the HMTL bundle, and in the XHTML bundle as well, there are snippets
> like this:
> 
> <h1>${1:`echo $TM_SELECTED_TEXT`}$0</h1>
> 
> activated via a tab trigger, "h1" in this case. I am completely missing
> the point here. Why is the echo command there? How can there possibly be
> a selected text when activating through a tab trigger?

There is of course always the menu you can use to activate the snippet,
in which case it would work. Or through some other hotkey.

> The way it is right now, if I type  h1, press tab, type my heading, and
> press tab again, the heading is selected. Was that the intended
> behavior? If so, could someone give me an example of how this is
> usefull? I haven't played much with html, so I might just be missing
> something obvious here.

That's a bug with the tab-trigger placements. There has to be a seperator
character between the end of ${1:...} and $0 (or $1 and $0).

> If this is not the intended behavior, should we change all those
> snippets to simply <h1>${1:heading}</h1>$0, or <h1>$0</h1> ? Are these
> snippets redundant in the presence of Ctrl-space, and if so would it
> make sense to have them have a slightly richer outcome, like <h1
> class"$1">...   ?

Adding $0 to the end is not necessary. And I don't think the <h1>$0</h1>
one has much value over the ctrl-space combo. So perhaps a bit richer
might be useful. But I'm guessing this snippet is mostly aimed at the
inexperienced developer or for wrapping a tag around some selected text
later.

Speaking of which, would there be some way of wrapping a selected text in
an arbitrary tag? I know I frequently run into that.

Jeroen.

-- 
            <http://www.je-ju.net/~jeroen/blog/>



More information about the textmate mailing list