Help with macro that changes lower case "i" to upper case "I"

Just bought a license for KM and successfully figured out a macro that fixed one of my persistent typing aggravations, mistyping “i” when I meant “I”. I had the macro always change the lower case instance when it was followed by a space. Works great, except this morning I discovered that I can no longer type HI without the “i” being capitalized (as you can see). Doh.

Thought of adding a space before the lower case “i” but then it wouldn’t work for starting a sentence with I.

Can someone help me figure out the necessary tweak to the macro to make it work properly? Thanks in advance.

After a couple of tests this seems to work fine:

Autocorrect i.kmmacros (2.7 KB)

Yes. That seems to work very nicely. I really appreciate the lightning response. Yours is quite a bit more sophisticated than my first attempt. I think I can learn from it. Thank you!


Hey Jeff,

Here's a little different method using a slightly simpler regular expression.


Auto-Correct Lower-case “i” when Upper-case “I” is Desired.kmmacros (1.5 KB)

Thanks. I’m not really a coder but I recognize that you both used expressions to define your actions. Is that one language or another? Is there a listing or guide to those expressions you can point me to? Sorry for the bonehead question. :slight_smile:

Yours is way simpler :wink: But doesn’t work with “i’m”. (But maybe this is not needed.)

My macro for I’ worked because it’s unique but the one I developed for simply lowercase “i” followed by a space didn’t allow for the word hi.

Well, basically you have


maybe some more?

Hey Tom,

True, and I don’t know.

The OP said “i” in isolation, which I took to mean the singular personal pronoun “i” either at the beginning of a sentence or embedded within a sentence.

Personally I don’t worry about this, because the autocorrect dictionary in Typinator handles that sort of thing for me.

I noted a few minutes ago that my pattern screws up when adding “-i” switches to the command-line though – so I changed it to something more similar to yours:

(?<!^|\S)i[ ]


Since no one else seems to have answered this question yet, I’ll take the liberty: those were regular expressions, and while different programming languages have different versions of them, they don’t belong to any particular language. You can find a listing of the regular expression syntax Keyboard Maestro supports here: Regular Expressions - ICU User Guide
and (one of many) tutorials here:

Thank you so much G. Problem solved and question answered in short order. Much appreciated. Feeling good about KM and the Forum.

1 Like

A very good starting point to Regular Expressions is the KM Wiki article about Regular Expressions. It explains the basics, gives you examples, and – if you scroll down – many very useful links.


@JeffH welcome to the forum. You’ll find lots of quick answers here of varying complexity from tons of helpful members. Regular expressions are crazy useful. Dig in to the links here and you’ll find many great uses for them. Again, welcome. :slight_smile:

P.S.: If you think a post has solved your problem you can check the “Problem solved” checkbox at the bottom of the post that solved your problem.

1 Like


This thread is a perfect example of one of my strengths or weaknesses, depending on who is judging. I will spend hours (even days) perfecting something that will save me 10 minutes a year, because I want it to be RIGHT. KBM caters to my strength or panders to my weakness - take your pick. I love it.

1 Like

Strength, of course.

Ahh, only joking.

Don’t forget to allow for your iPhone in the RegEx (-;