[TxMt] newbie question about text snippets

Guido Governatori guido at itee.uq.edu.au
Tue Oct 30 01:41:48 UTC 2007


Hi Janet,


> I am trying to find out how to insert an existing applescript into a
> snippet or perhaps a more elegant solution to inserting variables into
> snippets. Perhaps I need to explain:
>

Snippets are the first level of automation. In snippets you can use  
environment variables and shell code. You can set variables in the  
preferences.

For example the snippet

`echo $VARIABLE`

will insert the value of the variable VARIABLE, and you can use  
regular expression to do some transformations.

> I have many variations of boilerplate text that I use dozens of times
> during the day in my work that require a variable input in certain
> places. While I am not a programmer, I am all for automating  
> repetitive
> tasks and I'm not afraid of a little scripting. A little. Some of the
> stuff in those bundles looked downright scary.
>
> I was kindly directed to use the tab stops for snippets like this:
>
> ________________________________________________
>
> Hello ${1:firstname}
>
> Thank you for your order for a ${2:product}
> ________________________________________________
>
> Perfect. Easy. The next part, though, is to give me more control over
> the values I am inserting.
>
> For example, I have been using BBedit (which does the job but I don't
> particularly like) and in their "clippings" you can insert a
> placeholder that can call up an applescript to run.

For more complex insertions you can use TM_Commands. Commands are the  
second level of automation and can be inserted as snippet, and you  
can have contextual menus for them (cannot help with applescript).

All the best

Guido
--
Dr Guido Governatori
School of Information Technology and Electrical Engineering
The University of Queensland
Brisbane, Queensland, 4072, Australia
Phone: +61-(0)7-336 52907
Fax: +61-(0)7-336 54999
http://www.governatori.net/
http://www.defeasible.org





More information about the textmate mailing list