Why Is the Underscore Coming Out Twice?

I have a very simple macro where the entire job is to put an underscore on either side of a word so it will be italicized in Markdown.

I find it really tedious when I see a word I want to italicize and I have to click to the left, type an underscore, and then option-right arrow to the right arrow to get to the end of the word and then type the second underscore.

My trigger is the string underscore followed by a semicolon.

I then tell it to type an underscore with shift hyphen, then option right arrow and then another shift hyphen for the second underscore.

This has worked great for over a year, but just recently it started putting two underscores before the word and one after the word. What would have made this behavior change?

Running version 10.2.

Thanks in advance!

Markdown Italics.kmmacros (2.3 KB)

Hey Allison,

Welcome to the forum!  :sunglasses:

  • What version of macOS?
  • What changes if any have been made to it recently?

What happens when you use this macro?

Download: Markdown – Make Itallic v1.00.kmmacros (5.6 KB)


Keyboard Maestro Export

  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 10.14.6
  • Keyboard Maestro v10.2

What happens if you change the trigger to a hotkey trigger of F1?


I see you've changed the string trigger - I tried that and it works. I made mine hyphen semicolon, instead of hyphen shift semicolon, and I get one underscore instead of the duplicate. Good test, but I'm still baffled why the original one stopped working.

I see you're running Mojave - I'm running macOS Ventura 13.4. It would be interesting if my macro works properly in the older OS.

Thanks for the tip that I'm supposed to send the real macro. (See post #1)

Your editor is probably adding the matching "closing" underscore when you type the first in your trigger, so you are going from


to which the editor appends a _


which you then do two deletes on


and then simulate typing the underscore


before moving to the end of the word and adding the closing _.

Some editors are smarter than others -- I think Obsidian only adds the underscore when the next character is a space/line ending, and not when your insertion point is at the front of a word.

The behavior happens every single place I can enter text, not just in a particular editor.

And the real question is why did the behavior change? What changed either in macOS (I keep my system up to date) or in Keyboard Maestro (which of course I keep up to date as well.

Can anyone replicate the behavior with my Macro?

Your original macro works fine as is on my Mojave system.

Clearly something has changed on your system.

What is the answer to this question?

(Between the time your macro worked properly and stopped working properly.)

  • Have you updated the system?
  • Have you added any utilities to the system?
  • Have you checked your macOS System Text-Replacements?
    • These give a whole lot of people head-scratching problems when other text-replacement software produce anomalous results.

I appreciate the methodology of your questions but I thought I answered that when I said I keep my system up to date. I mean no disrespect, but Mojave went out of support two years ago so I'd sure like to see this tested on another updated macOS Ventura Mac.

The problem started a couple of weeks ago, and as an Apple podcaster the answer is yes I'm sure I've added multiple utilities and apps since then. Can't really narrow it down.

In those couple of weeks I've updated macOS twice - the emergency update and the 13.4 update. so I really suspect macOS itself.

GREAT question on the keyboard text replacements! Sadly none of mine use an underscore (I really hoped that was the right answer!)

Forgive me, but that’s a meaningless answer in a troubleshooting context.

Of course – but Mojave is what I have access to at the moment, so you'll have to wait for someone else to chime in.

This is a real (and relevant) answer...

Too bad.

Normally version bumps of macOS do not cause problems like this, so that’s probably a wash. (Although sometimes various user-settings get bollixed and must be reset.)

Under the circumstances I would suspect:

A) Some software you've recently installed.
B) Some macro you've created in Keyboard Maestro.

If I was going to chase this I'd do a safe-boot, launch Keyboard Maestro, and run the macro.

I'd also look at the Keyboard Maestro Engine log right after running the macro when it misbehaves.)

~/Library/Logs/Keyboard Maestro/Engine.log

See “Open Logs Folder” in the Keyboard Maestro Editor Help menu.

To go farther I'd create a new user on the system with the only 3rd party utility being Keyboard Maestro and test some more.

1 Like

Ooh - you're onto something. The behavior happens on both of my Macs which of course are syncing settings and Keyboard Maestro. But right now I happen to be in a secondary account where I have Keyboard Maestro pointing to the wrong sync file (I have that on my to do list to fix). The incorrect sync file does NOT have this macro in it.

So I typed underscore semicolon and I got TWO underscores!

This lends credence to your suggestion that it's some other goofy thing I've done that IS syncing through iCloud.

The good news is that I recently created an entirely new volume on this Mac and installed macOS Ventura from scratch on that volume. That will be a super clean test of the problem (that didn't occur to me to try till prompted by your questions.) I can't reboot right now because of a video project I'm working on but I'll report back on my findings.

...and then I kept poking at things. I thought maybe it was my clipboard manager, but it was not.

...and then I remembered what I did! I always forget that it's Keyboard Maestro I use to create this underscore, because it SEEMS like something that TextExpander should be able to do but it cannot. So I had tried to create a TextExpander snippet for it but it didn't work - but it was creating the double underscores!

Huzzah - thanks so much for sticking with me @ccstone - you were 100% right!