[TxMt] Re: Two issues with snippets

Guido Governatori guido at itee.uq.edu.au
Tue Sep 16 08:24:25 UTC 2008


On 15/09/2008, at 1:39 PM, Michael Sheets wrote:

> On Sep 14, 2008, at 8:31 PM, Guido Governatori wrote:
>
>> 1) I would like to create a snippet like (actually a part of a
>> snippet)
>>
>> ${1:[${2:text}]}
>>
>> So when I insert it on the first tab I have
>>
>> [text]
>>
>> with the option of deleting it typing <delete> and then on the second
>> tab to modify the actual placeholder. The problem is when I replace
>> the square brackets [] with curly brackets {}. I have tried a few
>> options with mirror and conditional insertions but to no avail. Any
>> suggestions?
>
> Try: ${1:{${2:text}\}}
>
Thanks. It works. I thought I have tried the solution above :-( but  
maybe I have not saved the file (it was called from latex  
configuration file)

Anyone with any suggestion for the other issue?

> 2) I would like to have a snippet for LaTeX superscript (and
> subscript) such that curly brackets are included when the content is
> at least two characters and no brackets when I have only one
> character, that is "^{abc}" and "^a".
>
> So far I have the following solution
>
> ^${1/(.{2,})|./(?1:{)/}$1${1/(.{2,})|./(?1:})/}$0
>
> but there is a few problems. When I have nested superscript (or
> subscripts) if the nested supscript is inserted as second character,
> then the caret is not at the right place. So if I type
>
> ^a^
>
> I get
>
> ^{a|^}
>
> where | indicates the position of the caret. The second problem is
> that if the first command triggers a snippet of a command, the snippet
> no longer work.


Regards

Guido

--
Dr Guido Governatori
http://www.governatori.net http://www.defeasible.org





More information about the textmate mailing list