Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TextWarangler macros?

8 views
Skip to first unread message

JF Mezei

unread,
Aug 5, 2021, 1:20:46 AM8/5/21
to


I need to change a bunch of these:

<!-- M02 Vancortlandt 2 -->
<gx:FlyTo>
<gx:duration>25.0</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
<Camera>
<longitude>-73.895308</longitude>
<latitude>40.893030</latitude>
<altitude>78</altitude>
<heading>199.1</heading>
<tilt> 65</tilt>
<roll>0</roll>
<altitudeMode>absolute</altitudeMode>
</Camera>
</gx:FlyTo>


into:


<!-- M02 Vancortlandt 2 -->
<gx:FlyTo>
<gx:duration>25.0</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
<Camera>
<neme>M02 Vancortlandt 2</name>
<longitude>-73.895308</longitude>
<latitude>40.893030</latitude>
<altitude>78</altitude>
<heading>199.1</heading>
<tilt> 65</tilt>
<roll>0</roll>
<altitudeMode>absolute</altitudeMode>
</Camera>
</gx:FlyTo>


In other words, copy the contents of the comment and then insert a new
line under <Camera> with a <name>xxxxxxxx</name>

What would be the best way to do this? Does the purchased copy of bbedit
have such function?


(In VMS, I could record set of keystrokes and then play them for instance
FIND <!-- , SELECT, FIND -->, COPY, FIND <Camera>,
RETURN, TAB TAB, type <name> PASTE, type </name>

and then assign this to a key and just press key repeatedly. ( there is
also a repeat command).

Just wondering if such functionality exists in TextWrangler of if I
upgrade to BBedit.


(the <name> is not technically part of Camera, but this allows me to
easily use PHP simpleXML to convert this to a set of placemarks and then
back to a Camera tour with the reciprocal script when I already wrote).
(There is a lot of trial and error because Google Earth insists in some
quirks such as turning camera towards the left before you begin a large
right turn).


Lewis

unread,
Aug 5, 2021, 2:35:24 AM8/5/21
to
In message <KyKOI.688$qf5...@fx07.iad> JF Mezei <jfmezei...@vaxination.ca> wrote:
> Subject: TextWarangler macros?

TextWrangler was EOLed five years ago. You should use the free
version of BBEdit.

> What would be the best way to do this? Does the purchased copy of bbedit
> have such function?

You do not need to pay for BBEdit to use its regex function.

> and then assign this to a key and just press key repeatedly. ( there is
> also a repeat command).

Once you write the rege you can simply say "replace all" and that will
replace all instances in the file. Or in multiple files.

> Just wondering if such functionality exists in TextWrangler of if I
> upgrade to BBedit.

I do not remember what TextWrangler supported, but I suspect it did
support regex. BBEdit is better, however, and has a fully supported free
version.

--
"Are you pondering what I'm pondering?"
"Well, I think so, Brain, but snort no, no, it's too stupid!"

Percival John Hackworth

unread,
Aug 6, 2021, 8:30:51 PM8/6/21
to
When I wanted to write some automation for BBEdit, I used the Applescript
extensions. That worked great for automating editing a file.

The "macros" you posted are nothing like the scripts for BBEdit.
--
DeeDee, don't press that button! DeeDee! NO! Dee...

Lewis

unread,
Aug 7, 2021, 2:53:22 AM8/7/21
to
In message <in62hn...@mid.individual.net> Percival John Hackworth <p...@nanoworks.com> wrote:
> On 04-Aug-2021 at 11:35:21PM PDT, "Lewis" <g.k...@kreme.dont-email.me> wrote:

>> In message <KyKOI.688$qf5...@fx07.iad> JF Mezei
>> <jfmezei...@vaxination.ca> wrote:
>>> Subject: TextWarangler macros?
>>
>> TextWrangler was EOLed five years ago. You should use the free
>> version of BBEdit.
>>
>>> What would be the best way to do this? Does the purchased copy of bbedit
>>> have such function?
>>
>> You do not need to pay for BBEdit to use its regex function.
>>
>>> and then assign this to a key and just press key repeatedly. ( there is
>>> also a repeat command).
>>
>> Once you write the rege you can simply say "replace all" and that will
>> replace all instances in the file. Or in multiple files.
>>
>>> Just wondering if such functionality exists in TextWrangler of if I
>>> upgrade to BBedit.
>>
>> I do not remember what TextWrangler supported, but I suspect it did
>> support regex. BBEdit is better, however, and has a fully supported free
>> version.

> When I wanted to write some automation for BBEdit, I used the Applescript
> extensions. That worked great for automating editing a file.

You do not need an AppleScript for the task described though, you just
need a regex.


--
Do not meddle in the affairs of wizards for they are subtle and quick
to anger.

JF Mezei

unread,
Aug 7, 2021, 1:39:06 PM8/7/21
to
On 2021-08-07 02:53, Lewis wrote:

> You do not need an AppleScript for the task described though, you just
> need a regex.


Can you provide an example of regex copying text from one area of text
and then adding text elsewhere (including the copied text).

I have only used regex to locate text and replace it.

Lewis

unread,
Aug 7, 2021, 8:55:11 PM8/7/21
to
In message <WyzPI.6849$EF2....@fx47.iad> JF Mezei <jfmezei...@vaxination.ca> wrote:
> On 2021-08-07 02:53, Lewis wrote:

>> You do not need an AppleScript for the task described though, you just
>> need a regex.

> Can you provide an example of regex copying text from one area of text
> and then adding text elsewhere (including the copied text).

Fred Smith
John Smthe
Alice Smythe

At its simplest,

search for "^([^ ]+) (.*)"
replace with \2, \1

Smith, Fred
Smthe, John
Smythe, Alice

> I have only used regex to locate text and replace it.

BBEdit manual (under the Help menu) has an entire chapter on regex/grep.


--
"Are you pondering what I'm pondering?"
"Uh... yeah, Brain, but where are we going to find rubber pants our
size?"

JF Mezei

unread,
Aug 7, 2021, 11:49:45 PM8/7/21
to
On 2021-08-07 20:55, Lewis wrote:

> search for "^([^ ]+) (.*)"
> replace with \2, \1


Thanks. wasn't aware there were "variables" in REGEX.
0 new messages