[TxMt] Re: Select and Replace: magic needed....
Scott Haneda
talklists at newgeo.com
Mon Jun 15 19:39:42 UTC 2009
On Jun 15, 2009, at 11:45 AM, Nicholas Cole wrote:
> On Mon, Jun 15, 2009 at 7:24 PM, Scott Haneda<talklists at newgeo.com>
> wrote:
>> On Jun 15, 2009, at 11:11 AM, Nicholas Cole <nicholas.cole at gmail.com>
>
>> 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?
>
> The problem with a regex is that the British use of single quotes
> makes apostrophes confusing.
>
> So:
>
>> This is `some of Jefferson's text'
>
> Needs to become:
>
>> This is \enquote{some of Jefferson's text}
Ahh, ok, I see. In that case, I believe you could fix the majority of
issues with my previous email. However, there should be a limited set
of these cases, 's being the most widely found one. I am sure there
are others, but you can certainly come up with a list of them.
You may want to then get a little hacky with the macro, and work on
the selection only. Here is how I would approach it:
1) Find 's replace to "something-you-will-never-have-in-your-code"
Repeat that find and replace with every 's style you can think
2) Perform a normal regex of find/replace as per previous email.
3) Find "something-you-will-never-have-in-your-code" replace to 's
Use different replace strings for each case.
You can work on making a smarter regex as well such as `(.*?)'(?!s)
* Credit to Alex Ross for that pattern
And you can simply add more !s type patterns to it for others. (Using
OR)
> A macro sounds interesting. How do I best make one of those for this
> purpose, then?
Macro's are very powerful because they are so simple to make. Simply
work out how you want it to work manually. Go to the Bundles ->
Macros -> Start Recording. When done with your work, in the same
area, select Stop Recording, this will bring you to the bundle editor,
for that macro. You then give it a nice name, and set a keyboard
command to it.
Since you want to limit the fallout on this, when you are working in
the find and replace window, hold down the option key, which will
change a button to say "in selection".
From there, you would just hit the key command, and it will run. It
is quote fast. I have done multi step macro's that do 30 or more
actions on a file, and it happens acceptably quick.
--
Scott * If you contact me off list replace talklists@ with scott@ *
More information about the textmate
mailing list