Quickly Insert Symbols

The palette is popped up with Option+Command+Q. Click on a symbol to insert it in your app. The palette will close.

Superscripts 1…9 can be selected by pressing 1…9 on the keyboard.

Subscripts 1…9 can be selected by pressing Option+1…9 on the keyboard.

You can easily change keyboard shortcuts and/or add symbols.

2221
Quickly Insert Symbol Macros.kmmacros (72.5 KB)

3 Likes

Thanks @ALYB Very useful for me. I only adjusted the size and background color.

Nice.

I have similar text triggered macros that map =sup2= to ².

Same for subscripts.

Text Expansions Macros.kmmacros (17 KB)

2 Likes

I've been trying to rewrite some of my macros to make them more efficient (smaller) and thought I'd apply some of my experiments to this task. It's been interesting.

Using Peter's approach of typed string triggers but changing the Switch action to hunt a Substring reduces the size of the two macros from 17K to 6K. Here's the approach:

ss-474

Text Expansions II Macros.kmmacros (6.1 KB)

Replacing the Substring with an Execute Shell Script using Perl maintains the 6K size for the package (although I'm only showing one here):

ss-475

Text Expansions III Macros.kmmacros (6.0 KB)

But what about ALYB's palette (which is rather attractive)? I used an HTML palette to do that (which is one macro that does both superstrings and substrings plus a few other special characters, all of which have tooltips when you hover over them).

ss-478

That, too, is just 6K:

SubSuperScript Macro

SubSuperScript.kmmacros (6.0 KB)

Keyboard Maestro Export

I defined the list in a format compatible with the Prompt with List action to experiment with that. But it could be written more efficiently for this approach.

There is an issue with the display of the superscripts and subscripts in the HTML prompt (the superscript vary in size and the subscripts have their bottoms clipped). Any ideas why?

But that's a nice savings going from 72.5K to 6K with a full palette of special characters at the same size as typed strings for just super/subscripts.

3 Likes

Nice but another way -- @peternlewis baked into KM is with simple variable arrays. Unless I'm missing something, this performs the same thing.

@Subscripts.kmmacros (2.5 KB)

2 Likes

Thanks, I was looking for that indexing trick. It does result in a smaller pair or macros (5.9K), too. Again, a lot less than the 17K version.

This is one of the "efficiency" issue I've been wrestling with. If you can make one macro do the work of two, you'll save space. In this case, enough for a lot of other special characters in an HTML prompt, which surprises me. But I'll take it!

2 Likes

At the risk of stating the obvious -- disk space is cheap, processor power less so, and time is money. You need to decide what measure(s) of "efficiency" you want to use.

@peternlewis's Switch/Case version is easy to put together, easy to understand, easy to maintain. It's bigger than your Substring version and runs slightly slower (~0.5 seconds over 1,000 runs on my machine).

Your Substring version is a little trickier to create, understand, and maintain, but smaller and slightly faster. Sweet spot!

The perl version is trickier in all aspects, similar size to the Substring one, but runs at only a third of the speed.

@kcwhat's is teeny-weeny (and I love the array access method!), roughly as tricksy as yours, but runs about the same speed as @peternlewis's.

But -- totally IMO -- the biggest part of the TCO of a macro is the time spent creating and fiddling around with it. Using the methods that are quickest for you to write and maintain will be more "efficient" than saving a few kB or milliseconds here and there.

Of course, if you're like me and find going back to tweak and optimise macros strangely therapeutic -- then it's less a "cost" and more a "benefit"!

2 Likes

@Nige_S - I should sue you for saying this in public.... :skull:

2 Likes

There's another factor much on my mind. A while ago Peter talked about the size of the plist file (Keyboard Maestro's macro file), which I think I discussed in the documentation for Brevis -- Automating Text Expansions.

So, as a matter of ingraining best practices, I've been looking at different ways of constructing a macro to save space.

I've been surprised that there's not much penalty for using a Custom HTML Prompt over a Prompt with List, even tossing in CSS and JavaScript. And the jury is still out on subroutines, which I thought would be a slam dunk.

No doubt that should be balanced against the time it takes to put things together as well as performance issues.

But for me, the smaller my plist, the more time-saving macros I can indulge in without penalty. (And, yes, it does seem to be therapeutic!)

2 Likes