Select Specific Text in an Open Document and Bold It

Hi Km Forum Friends!

I've been searching for a solution for this to no avail. It seems like I need to be using regex but this seems daunting to a newbie like me.

How can I use KM to search for, and bold, specific phrases i.e. "Account ID"

Thanks!

Hi, @Ihventura_Hutch; for inexperienced users, I like to provide the following links:


Without knowing more about your objective (e.g., what application; example text) it's difficult to advise. With that said, I'd generally try to use the native features of the application and automate the control of the app with a Keyboard Maestro macro. For Microsoft apps, I sometimes use VBA instead.

@_jims

Say, I have a document populated with text. I want to search for, and bold-text certain words and phrases, like "Account ID", "Profile ID", "Console Errors", using jira markup (asterisks)

For my use case- whenever any of those phrases are in the open document I am working on in sublime, I want those phrases to be bolded.

Ideally, using the system clipboard and regex (I assume), but haven't been able to figure it out, except for- "double click on found image", which is clumsy.

I want keyboard maestro to scan through the entire document, and BOLD any of the words I have included in a list.

Also, I am using Jira markup. So really, I am appending/prepending asterisks, to specific words I find in my documents, commonly.

So, in Sublime.
Example text:

So, this....

• Issue Description : 

• Expected Result: 

 
• Actual Result:

Member's name:
Member's email:

LIAM Approved:
Account Name:
Profile ID:
Account ID:
Profile Requirement:
SSO:

Becomes this.....

• *Issue Description*: 

• *Expected Result*: 

 
• *Actual Result*:

*Member's name*:
*Member's email*:

*LIAM Approved*:
*Account Name*:
*Profile ID*:
*Account ID*:
*Profile Requirement*:
*SSO*:

Couldn't agree more. Unfortunately, Sublime Text doesn't seem to offer much. They don't provide an AppleScript dictionary; they do provide a command line interface, but there doesn't seem to be a way to do something like Get Content of Current Document.

Your best bet may just be using the clipboard, and while regex is powerful and could do the job, you might have an easier, cleaner time using Search and Replace with standard strings.

Here's a quick sample you could modify to your liking:
Replace Clipboard - Bold Keywords.kmmacros (2.5 KB)

To keep it simple, the workflow is Copy -> Run Macro -> Paste. You could streamline this to your needs.

1 Like

Hi, @Ihventura_Hutch. On my Mac this approach seems to work.

Modify Specified Text.kmmacros (13 KB)

Macro Image ( expand / collapse )


Note that the actions that load the clipboard and paste the modified clipboard are disabled. If you want to fully automate the process, enable the two purple groups (but be cautious as the macro will modify the text in the Sublime Text frontmost window).

1 Like

Good one, @_jims, this is a much smarter approach.

2 Likes

Thank you @_jims @avtraino !!!

This is just the best forum ever. Thanks for helping a stranger in need!

3 Likes