Double-clicking a word in Pages selects that entire word. However, I want strings such as D#m7/b5 to be treated as word - i.e. it's not a word, but I want the quick action benefit of double clicking it (or similar easy shortcut) and selecting the entire string between spaces.
As far as I can tell, no keyboard shortcut while selecting text does that. How could I set up an automation for that in keyboard maestro?
Unfortunately – you can't change the macOS' or any old app's double-click behavior at any level that I know of (other than speed in the system mouse prefs).
Some apps (usually programming editors) may have preferences to allow adjusting for camel-case or variations of it but not many.
What you want to do is not going to be instant, because you'll have to position the cursor at the start or end of the “word” and then:
Iterate through it letter by letter with Shift-Arrow to select.
If you were working with an app like BBEdit (which is highly AppleScriptable) then a scripted find with regex might do the job, but Pages doesn't have the smarts.
If your intent is truly to select a chord name, you'll have to use @ccstone's (which does work for me). But if your goal is to copy the chord name to the clipboard, try this:
It gets the last non-whitespace run of characters before the cursor, the first non-whitespace run of characters after the cursor, puts them together, and then puts that concatenation onto the clipboard. Its main downsides are:
It gives no visual indication of what's on the clipboard.
The text that's put on the clipboard is plain text—no formatting.
There's some visual "noise" as the portions of the current line before and after the cursor are selected.
Still, it works pretty quickly, and it will copy the chord name whether the cursor is immediately before the name, immediately after the name, or anywhere within the name.
My crazy idea will almost certainly not be something you want to try, but it's so delightfully crazy that I want to mention it. Just for the fun of it.
Step 1. Take a screenshot.
Step 2. Pass the screenshot to Monterey shortcuts' OCR (discussed on another thread)
Step 3. Filter out the text that doesn't contain chord names. (not too hard)
The resulting word that appears is probably the word you want. Because Monterey OCR does not "break up" text.
clicking anywhere in the chord string, so that it contains the cursor,
using ⌥ left arrow, then ⌥⇧right arrow
and if that seems to work wherever you are converting chord codes to graphs by applying a font, you could try inserting those two key strokes before the copy event in the main macro itself:
Yes, I was looking for it to work as a prelude to your macro. However, that would still require up to 4 keystrokes to select with a keyboard. That hardly competes with a mouse selection.
As for applying a font style, I do it by line, so no need to select individual chord names in this case. Did I misunderstand you?
I see ... I wonder if I'm missing something ? If those two keystrokes are built into the macro itself, don't you just place a cursor in the code and launch the macro ?
@ccstone thanks for your input. It works relatively well, with some cases dropping. My biggest issue is that I have to be at the beginning of the string. This is not biggie, however my ultimate automation would be to just place the cursor just anywhere where the string is and the selection would be done for me by the macro then. Much like a double click does with actual words.