Using Execute Shell and SED Stream Editor to Change TextEdit Margins

Based on a suggestion from @ccstone, this macro has been reworked, even before I finished documenting the first version. The version in this thread works, if you want to try it as is, but it uses Execute Shell Script in places where there are KBM actions to do the same task, making it harder to modify. The updated, simpler, all KBM version is being posted to the Macro Library section of this Forum as

I've been working on a Keyboard Maestro way to change margins in TextEdit. It's a work in progress so there are several things that I'd like to have it in that I haven't implemented yet, but in its current form, I'm finding it pretty useful.

I'll come back and explain this in much more detail. Unfortunately, I don't know how to save a draft that isn't public.

=TextEdit Macros Macros.kmmacros (133 KB)

Keyboard Maestro Export

The core of the edit is in the M05 macro:


There are two enhancements that I want to make, which I haven't started but which would make the user experience a bit smoother.

The first, simplest, is to replace the last macro in the series, M06, with one which automatically clicks the Revert button instead of instructing the user to do so. Simple in KBM, I just haven't gotten to it.

The other is to have a better interface for setting the desired margins instead of the current M04. Right now it's just a Prompt With List that currently has eight simple choices. I imagine this would be an HTML Prompt that would show the current values in the file and give you a chance to edit them individually, change units between TE's half-point scale to points, inches, centimeters, etc.

One of the many reasons I use it as little as possible...

Have a look at Jedit Ω. I've been using various incarnations of this critter for over 20 years.


Keep in mind that Keyboard Maestro can easily search and replace in a file.

There's no need to resort to sed, unless you want to.

1 Like

Well, I never! Nope, I had never encountered that before. Looks like just the right thing. For a public macro, I'll take a look at it as a simpler, more maintainable and editable way to go and edit this macro accordingly.

As for SED, I've been an addict for decades, from back when that's all there was. Recent versions of SED, from this century or even the 90s, have a comment syntax but the original did not. So very early in my SED career I rolled my own.

This command \
will NOT (!) change (c) \
anything to the contents \
of this text block, \
which ends at \
any line that does not \
end in a backslash \
so my personal convention \
was to use the reverse \
of the opening, i.e., \c!

I will. It looks interesting. Longevity is good to know about.

I'm using TE as a default example in some tutorials I'm working on because it comes with Mac.

1 Like

Thanks for the tip, @ccstone.

I've replaced the Execute Shell Script running SED with this:

It works. I don't even have to make a temp copy of the file.

I'll update the macro and complete the doc soon, I hope.

1 Like

I've posted the updated macro set in the Macro Library section.

How does this compare to jEdit @ Coincidental name only? Different flavors of the same base? This one is free and open source.

I'm having trouble finding a feature comparison to see what I would get in the Jedit Omega Pro version for ¥2400 vs the free version. What are the biggest differences for you?

You could figure that out with a couple of minutes of research...

jEdit is a JAVA based programming editor that hasn't seen an update since 2020 and requires JAVA to be installed on your system. It had some useful features, and I kept a copy on my system – until I gave up on JAVA.

Jedit Omega (an entirely different product) is a modern styled-text editor that is feature-rich, has regex support, and is AppleScriptable.

The most recent version ⇢ 2.47 ⇢ released 2022/09/23.

I haven't seen the free version for 20 years, so I have no idea of what the diff is anymore – but an enterprising young man such as yourself could probably find out with a little effort.

Artman21 Inc. Contact Info

Satoshi has been pretty responsive to inquiries over the years, but I haven't talked to him for a while.

Perhaps, but at my age I've learned, and re-learned, not to immediately jump to reinventing the wheel and to ask for help when I get stuck. After what I considered a reasonable amount of looking, in fact more than that because it was getting unenjoyably frustrating, I could not find the standard kind of feature comparison list on their site, so I asked the person I knew who had the most familiarity with the product for their opinion, which seemed reasonable given the fact that they had specifically recommended the product to me.

Thanks for the history.