How Do I Use KM to Create Thousands of Auto-Correct Text Expansion Macros?

Hi all

so after going from novice to less novice in my KM macro skills its time to finally conquer text expansion in KM :smiley:

the normal replace macros are easy but having been using emacs for the past 10 years i have this macro there i love where each time i misspell a word and check that word (via spell checker) the wrong+right word are added to my library and now each further misspell in the future will auto correct this for me!
is something like that remotely possible in KM?
Would love to hear everyones thoughts on this.
Also very related: can anyone recommend a english pre build common mistake correction library for KM?



Corpora of misspellings for download

I can kind of envisage a roundabout way of doing this if one didn't use the built-in spell checker, but wrote a script to perform the spell check themselves. Then, from within this script, it would be fairly simple to isolate the mistakes and corrections and return them in pairs.

The two issues are:

  1. Writing your own spell checker: this is not an insurmountable task using AppleScriptObjC's NSSpellChecker class methods;
  2. Do you want to have to employ a separate method to perform your spell checks ?

I'm just brainstorming out loud here. I don't actually know of the feasibility and/or practicality of this idea.

Thx so much for the reply @CJK !

this is cool but is there anyway to import these lists into KM? i mean there are 36,000 corrections there so I assume i would need 36,000 macros? :slight_smile: is there a better way @peternlewis and community?

building a script is way over my head at this stage :smiley: but appreciate your thoughts on this



KM is really not designed to handle that number of macros.
For this task, I'd suggest Typinator.

It works very well with KM, and every other app I know of.
I've been using it for years.


I second this. Typinator is excellent, and AppleScriptable, which feasibly makes automating the creation of new text replacements from, say, a 36,000-words list doable.


thx a lot @CJK and @JMichaelTX!

i have been looking in recent weeks at PhraseExpress and Typinator also looks great and now dilemmas again :tired_face:

anyone used both and can compare from experience? would love to get some thoughts before i commit to one :smiley:

from playing with both each has advantages..PE has a ios app and syncs nicely between while Typinator seems very light weight, you can export your phrases easily to open standards (don't think PE has that) and you both highly recommend it :slight_smile:

thx again


As stated, do not add 36000 text translation macros to Keyboard Maestro. It is really not designed for that, and the results would likely not be pretty (and certainly not something I would be concerned about supporting).

In theory, you could create a single macro with a regex trigger, and then process the conversion, but frankly I would not advise this either - use an appropriate tool for the job if this is something you want.

thx everyone for you valuable comments!

i picked typinator based on your high recommendations and exploring it now

wish they will have a ios version in the future... :slight_smile:


I very recently (2 days ago) solved a problem with Typinator that has some key elements similar to your situation, @zeltak.

Writing AppleScripts using its Objective-C flavour often means endlessly writing out lines that look like:

property NSArray :  a reference to the current application's NSArray

Your post inspired me to solve this by creating a list of every single class (e.g. NSArray) available in Objective-C (of which there are over 12,000, which I filtered down to the 10,720 parent classes that all begin with two capital letters), and then created a single regex text replacement rule in Typinator that allows me simply to type a word followed by a colon and, if that word appears in the file I mentioned, have it expanded into the format above, e.g.:



property NSSpellChecker : a reference to the current application's NSSpellChecker

It has brought a lot of relief from previous scripting tedium. From this experiment, I have no doubt you can take one of those lists of misspellings and create a single rule in Typinator to cover all 36,000 misspellings, although you would benefit your system a lot if you were able to go through that list manually and eliminate words you are rarely or never going to find yourself typing.

EDIT: In fact, I just went and did it. I downloaded the big 36,000-word long file referenced as "Birkbeck", and reformatted it from:



$word₁ misspelling₁ misspelling₂
$word₂ misspelling₁

(Here's a copy if you need it: [116.7 KB])

Then, I created an Application-specific rule assigned to operate only in TextEdit for purposes of testing:

Regular expression: (matching whole word, case-insensitive)

[^ ]+

Expansion: (plain text)

word=($(grep -E -i '\s$0\b' ~/Desktop/missp.txt))
[[ -n "$word" ]] && printf '%s' "${word#$}" || printf '%s' "$0"

Works surprisingly well and speedily. This is just a proof-of-concept with a list I think is far bigger than is necessary, as the words you'll likely need correcting on a day-to-day basis will fit into a list of about 200-300 max.

This missp.txt list also contains spelling "errors" that can't really be said to be erroneous, but stem from—I imagine—some university students submitting papers with "this" being typed instead of "his". At first, I thought my Typinator rule was misbehaving when I went to type "This is a test" and ended up with the phrase "his I I choose". But, upon examination of the file, under the words "his", "I", and "choose", you will, indeed, see alleged misspellings of these words that my Typinator rule was correct in substituting in this nonsense.

that’s amazing, ill try it tomorrow at work :smiley:

off topic a bit to you and @JMichaelTX on typinator. You guys mentioned the scripting capabilities and KM integration. If i want to include in one of my snippets the ability to change the input source (language) when i launch that expansion, do i use apple script for that in the abbrv itself or call on KM for that?
can anyone share an example for such a process?



I hope you don't mind that I have revised your topic title to better reflect the question you have asked.

Km and auto correct, a way to quick add common mistakes to my KM text expansion library

How Do I Use KM to Create Thousands of Auto-Correct Text Expansion Macros?

This will greatly help you attract more experienced users to help solve your problem, and will help future readers find your question, and the solution.

@JMichaelTX sure thx a lot for correcting this!



1 Like