Interactive text expansion?

I take a lot of notes (typing), and abbreviate various words along the way. A lot of those abbreviations are standard (e.g., bc for because), but others are very context dependent (e.g., auth could be authorization or authority, depending on context).

I explicitly don’t want these abbreviations to expand while I type (I already have trouble with some TextExpander abbreviations, since I’m often typing faster than they expand). But when I go back over my notes it can be helpful to expand them, especially if I’m summarizing parts of the notes for other people.

I’d love to be able to highlight an abbreviated term, or a block of text with abbreviations, and have an opportunity to select from multiple options. Presumably, I’d have to populate a custom dictionary.

I could probably cobble something together on my own, probably using Popclip, but first I thought I’d see if anyone has any suggestions for off-the-shelf tools, or approaches to accomplish this.

If by context you mean the file you are editing, or application you are using, then you could use Typinator and have different sets of replacements enabled. These would expand as you type, of course. I haven’t used TextExpander, but Typinator is really fast.

If by context you mean paragraphs, then the above wouldn’t work.

To me, real-time expansion would require less effort on your part, as you wouldn’t have to go back through the document, and risk missing an expansion (i.e. that your brain thought you had defined, but you hadn’t).

I tried an autocomplete setup at one time, but it never predicted what I wanted, and the huge number of choices available made it more efficient to just type the words.

For your specific example, just noting you could define authz and authy. I tried things like this too, but it’s too hard to remember the abbreviations that are defined.

Thanks for the thoughts.

Unfortunately, I’ve been doing this long enough, trying to change the way I take notes (which has its roots in handwritten notes) would be more disruptive than manually expanding abbreviations after the fact.

I can’t take the time while typing to remember to use authzinstead of authy etc. So even if Typinator is faster, the multiple possible replacements undermines autocomplete

@tf2 This is an intriguing question. I can see useful applications of the idea but I have never seen any application that can do it out of the box.

Popclip is an interesting thought but I think the challenge you will run into is how to maintain a custom dictionary/database that Popclip can access.

The best way I can think of to do this would be using Apps Script with Google Docs. You cannot modify the right-click menu in Google Docs but you can add a sidebar which could bring up your custom options for a given highlighted word.

That does assume you are willing/able to do this in Javascript/Apps script. I don’t think there is a simpler way but I would be interested if there were.

1 Like

Actually, I think I could do it in Hammerspoon – store the custom dictionary in the Kia code, or read it from CSV or yaml in a file…

Hammerspoon does look pretty ideal for the task

I was impressed with the Hammerspoon docs when I looked at it a while back - but then I realized I would have to master Lua. Considering that computing is an important tool for me but not my main occupation, I decided mastering a general-purpose tool like Javascript or Appscript or Applescript or Shortcuts makes more sense than learning Lua which I probably would only use for this one purpose.

But that said- if this project would be something you make use of very regularly, then Lua and Hammerspoon might well be just the toolset for you.

1 Like

I agree that it doesn’t make sense to learn lua just for this. I already dabble in it with Hammerspoon for some other automations, and it’s similar enough to the python and (little) JavaScript I know that I think I can make it work.

Of course, if I knew JavaScript better, may be I could do it in JavaScript for Automation…

Perhaps a Grammarly Custom Style Guide would do what you want?

If not then perhaps another grammar checker is customizable to do as you wish?

if you have keyboard maestro, create two macros, both using the same text trigger as in this screenshot where i used ,au

second macro

Thanks! Interesting idea. At $15/month just for me and just for this feature, it’s a bit steep, but it would be a great approach otherwise. I bet there are other ways to implement a custom dictionary though…

If you have the ability to write JavaScript I am wondering if you could use Alfred’s Universal Actions to trigger an Alfred workflow. The workflow would run the JavaScript that would take the selected text and search a dictionary (a text file with a list of words that you build) and give you the option to select from the words that start with the selection.

Quite a bit of scripting but conceptually not complicated if you keep your dictionary sorted.

I don’t know if this is practical, but I think it could work. :grinning:


I like the approach. I do t use Alfred, but I’ve sketched out an approach using Hammerspoon, which has a built in chooser. I could do it in Keyboard Maestro, but I’ve found Hammerspoon a little faster (and easier to troubleshoot) for simple interactions like this.

It doesn’t appear you really want interactive (as you type) text expansion. You want to use your abbreviations undisturbed as you make notes.

And I note you use the same abbreviations for different words used in different contexts, which makes this more intriguing, as murder mysteries go.

How about this:

  1. You keep notes the way you do now. No changes.

  2. When you want to read the notes, you open them in a text editor like, say, BBEdit where you can Apply Text Filter to convert all your abbreviations at once in the blink of an eye.

  3. You save that version of your notes for future reference, overwriting the abbreviating original version.

If that works for you, all you need is a simple Perl script in which every line represents a substitution. For example, to expand bc as a word to because safely (leaving bobcat alone):


And to handle something like auth that needs context (if you can describe the context), you might try this sort of format, recognizing the first one takes precedence:

s/(whose|your|mine|their|our|my|the) auth\b/$1 authorization/g;
s/(is|be) auth\b/$1 authorized/g;

All wrapped in a Perl script stored in BBEdit’s text filters directory:

#!/usr/bin/env perl

$_ = <STDIN>;

s/(whose|your|mine|their|our|my|the) auth\b/$1 authorization/g;
s/(is|be) auth\b/$1 authorized/g;

print $_;

That turns:

This is bc a bobcat is auth to approve the auth.


This is because a bobcat is authorized to approve the authorization.


1 Like

I’ve tried similar approaches (though not BBEdit, which is a good idea).

The problem is that I really do mean I want interactive replacements – I need to see the specific abbreviation and choose the substitution; it can’t just replace by algorithm.

Think an old-school spell-checker – you run it, it finds each misspelled word, and offers to change it, giving you a choice of replacements if appropriate. You choose what change to make, if any.

What won’t work is the equivalent of autocorrect, either while I type or after the fact.

I see what you mean now by interactive. If you can’t avoid that with more specific abbreviations, you can implement a custom dictionary for your abbreviations that would display a list of possibilities for each ambiguous abbreviations.

Here’s one approach: Spell Checking Many Posts With Aspell and a Custom Dictionary.

1 Like

I am convinced that the genre you are looking for is a customizable grammar checker.

If Grammarly is too steep in price for the purpose then maybe one of the open source alternatives would work

You are both pointing me in the right direction. Thank you!

I can’t help thinking that the simplest solution would be to use text expansion as you type. You say it would be too difficult to remember when to use “authy” (which I have actually been using for years as an abbreviation for “authority”) or “authz”. I don’t know what sorts of abbreviations we are talking about here, but if you develop your own system of abbreviations, it soon becomes second nature. For example, words ending in -ize → -z (in my case, chr → character, chrz → characterize), words ending in -ization → -zn, etc. Just a thought.