Replacing underscores in lyrics with nonbreaking spaces

Very annoying that when Dorico imports a .musicxml file from Finale, for non-metered lyrics (several words on one note), the nonbreaking spaces which Finale puts between the words get imported to Dorico as underscores and therefore appear as elision slurs so the lyric‿render‿like‿this, instead of simply like this. And since Dorico lacks a project-wide text search-and-replace command, I’ve been having to replace each underscore in each lyric manually.

So tonight I tasked Claude Code with making me a macOS Services bundle which changes underscores to nonbreaking spaces in the selected text. You still need to select each such lyric, open for editing and Select All, but then just one more click to do the search-and-replace. Much easier.

Installation instructions are in the ReadMe of the attachment.

We tried making this Service do the Select All too, but that requires a more exotic Service with access to System Events, for which permissions must be granted in System Settings, yada yada and I decided this feature would be too fragile.

ReplaceUnderscoresWithNBSP.zip (3.2 KB)

For any mechanical text manipulation, I just copy the whole thing from “Edit Line of Lyrics”, and paste into BBEdit, where I can perform any process I need to.

I think I would have used the Edit Line of Lyrics, copy it and paste it in my favourite text editor (TexShop or Sublime), search and replace the _ with a space, copy the result and paste it back in the Edit Line of Lyrics window… But ok, if you prefer involving Claude, that’s your right.

Ninja’d by @benwiggy

Thank you for the tips. Using Edit Line of Lyrics… will make using my service even easier in some cases. My service eliminates the detour through BBEdit.

Just in case there is someone else who was not aware of Edit Line of Lyrics…, the path to the command is: main menu > Edit > Notations > Lyrics. It is also available in contextual menu.