Autocorrect TWo-Letter CApitalized words

I’m constantly making the error of CApitalizing the first TWo letters of a word when I don’t want to. (I can’t remember ever wanting to, anyway.)

There’s a good discussion here of how to capitalize words when you’re typing, but does anyone think it would be possible for KM to look at every word as I type (triggered, say, when I hit ‘space’), and use a Regular Expression (maybe?) to detect this pattern – and if it happens take it away to a named clipboard, change the second letter to lower-case, and return it to the same spot?

Grateful for any advice, as ever.

yours
Michael

I have also been looking for exactly this macro, but do not know how to do this.

You could do it with a regular expression trigger like this:

\b[A-Z][A-Z][a-z]

You might find if you type sufficiently fast that you can type a fourth character before Keyboard Maestro can correct the second character. You can possibly improve the speed by turning off the simulated deletes, and only deleting two characters and adding the two lowercase characters.

Fix TWo.kmmacros (2.2 KB)

Manually delete version:

2 Likes

Thanks! You guys are the best. :slight_smile:

This is great thanks. Now I can ditch MS Word and use text editors like Byword etc.

The only amend I made for this was to change to title case as it was not workig on capitallise.

AS

Hi Peter,

I found a small problem about this macro. For example, I don’t want to autocorrect the word “TVs”, but this macro will do. By the way, the “filter variable with Capitalize” is better in this macro.

To solve that problem, I made two macros. One is the exclusion macro, and the other is the main macro.

The Regex I use here is \b[A-Z][A-Z][a-z]+[A-Za-z]*[^A-Za-z]. These two macros will trigger after a whole word is typed and a next key (not a-z) is pressed, because I want them to check exclusion words for me.

However, I have another problem here. If I type the word “APple”, and click somewhere with my mouse, these macros will not trigger.

Do you have any idea about this, like the string can be triggered after I type a whole word or anything else?

Thank you.

<img src="/uploads/default/original/2X/f/f98f9f8997e7fef7482ff0798809d35db42f7167.png" width=“603” height=“auto">

<img src="/uploads/default/original/2X/e/e5407b46c82e66445d463a8e05fccf4a939d7b18.png" width=“527” height="auto”>

To catch TVs, make some sort of exclusion list, like this:

\b(?!TVs)[A-Z][A-Z][a-z]

No. Keyboard Maestro has no ability to help in that sort of case - you have left the field or clicked somewhere else in it, either way Keyboard Maestro cannot affect the previous location.

In fact, Keyboard Maestro knows nothing about what you are doing or where you are doing it - all it sees is what you type. Various things like clicking or changing applications clear the buffer of what keys it is looking at.

I see. Many thanks for your help.

I would love it if this one was revisited. It is just not fast enough for rapid typing.

Yeah, I sympathize. My Double Caps in the Toggler Macro thread (at the bottom) works great (and has an exception list) in text editors but isn't quick enough in desktop publishing applications (generally speaking). I suppose Typinator is the solution to this.

@peternlewis Is there a way to have this macro wait for a pause in typing, before correcting the double capitals? Thanks for all your time over the years.

Do you want the lack of a pause to nullify (ie, not make) the correction, or do you want the correction to still be made after a short pause? The answer will depend on what you want.

Thank you for your response!

When I’m typing and the macro triggers, it interferes with the correction of double capitals. This is because my ongoing keystrokes disrupt the correction process.

For instance, when I attempt to type ‘HElow World’, I end up with something like ‘low HHeworld’.

Here are some actual examples:

HELlow World lowHEl world Low HElWorld

However, if I type ‘HEe’ and pause, allowing the macro to correct the double capital, I get the corrected ‘Hel' and then can add the 'low World' once it's done.

So, if the macro could be programmed to wait for a pause in typing before it activates, the correction of double capitals could be executed properly.

I hope this explanation is clear.

Thank you!

In your last two messages you refer to "this macro" and "the macro" but when I scroll back there are different macros being discussed, so I don't know which one you are referring to. If you show the contents of the macro that you have activated, that would help.

Thanks Airy!

It's the one from Peter N Lewis

I'm really scared when I post anything that suggests that PeterNLewis was wrong, because it's usually me that's wrong, but the Title Case filter that he put in that macro doesn't decapitalize the second letter. Look closely in these conversions in the image below. The one you were worried about, which is the second one in this list, is NOT fixed by this action.

image

Basically the Title Case filter ignores any word that has a capital letter inside the word. So this is not what you want.

There is a second problem in his macro, which he explicitly identified. That is, you might type too fast for this macro to work all the time. He described how you might be able to fix that, but I can see you didn't make that change.

My first question for you is why are you trying to use a macro to fix this, when macOS already has a feature that fixes this, called spelling autocorrection. It specifically solves the problem, and works 100% of the time. When I type "CAnada", it fixes it automatically. You can enable this feature in System Settings, Keyboard, Input Sources, Edit, "Correct Spelling Automatically (ON)." Have you tried this feature?

For what it's worth: I just wanted to change a setting in my TextExpander (last version without a monthly payment), and I noticed that TE also provides a mechanism to correct unintended double capitals: