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

Steve King sking at arbor.net
Mon Jun 15 19:40:48 UTC 2009


Alex Ross wrote:
> You need smarter regex's :)
>
> How about:
>
> `(.*?)'(?!s)
>
> So it starts by matching `, and matches until it finds a single ' that  
> is not followed by “s”.
>   

It will still fail in too many cases, such as plural possessive.

    Alice said, `I need to fill my two cats' water bowl.'

Anyway, on to the macro.

1. Highlight the text you want replaced. For this macro, highlight
everything inside the quotes, but not the quotes themselves.
2. Press ⌥⌘M (alt-option-M) to start recording a macro.
3. Press ⌘X (option-X) to cut the highlighted text.
4. Press → (right-arrow) to move past the closing quote.
5. Press ⌫ (delete) twice to delete both quotes.
6. Type: \enquote{
7. Press ⌘V (option-V) to paste the text you cut earlier.
8. Type: }
9. Press ⌥⌘M (alt-option-M) again to stop recording the macro.

Now, to use the macro you simply need to highlight the next bit of
quoted text and press ⇧⌘M (shift-option-M). The macro will be replayed,
repeating the same sequence of operations outlined in steps 3-8. If you
like you can save the macro with ⌃⌘M (control-option-M) to use at a
later time.

-- 
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com <http://www.arbornetworks.com/>




More information about the textmate mailing list