[TxMt] Re: Select and Replace: magic needed....

Scott Haneda talklists at newgeo.com
Mon Jun 15 18:24:45 UTC 2009


On Jun 15, 2009, at 11:11 AM, Nicholas Cole <nicholas.cole at gmail.com>  
wrote:

> Dear All,
>
> Many years ago, in a state of innocence, I hard-coded my LaTeX  
> quotation marks.
>
>> Thus I have text that `looks like this'.
>
> I now find that it would have been MUCH better (if not essential) to  
> have done:
>
>> Thus I have text that \enquote{looks like this}
>
> I can't do a search and replace, because there is no algorithm that
> will get the quotes right, but I would like to be able to do the
> following:
>
> 1. Select the text that needs changing with the mouse
>
> 2. Hit a key and have the text changed to the \enquote version.
>
> I feel like this ought to be the sort of thing that TextMate excels
> at.  How should I do I

How about a macro? It could take cursor position, expand outwards  
until it finds your left most quote after whitespace and then finds  
your right most quote followed by whitespace.

 From there, it is just a matter of swapping in your substitution data.

Curious... Is your desired text to change always structured the same?

Why not use a regex based find and replace and connect that to a hot  
key via a bundle?

Perhaps show us a small sampling of all the possible input data you  
are looking to transform.

Sorry I can not provide examples, still waiting on textmate for  
iPhone :)
-- 
Scott



More information about the textmate mailing list