MACRO: Augment or Transform Text, v7.0

This macro was formerly named: Augment or Filter Text.

If you have a version prior to Version 7.0, you will likely want to disable it before using this version.

Examples: Selecting from the Menu

Augment or Transform Text 1a


Examples: Using Immediate Actions

Augment or Transform Text 2


PURPOSE

This macro is used to modify the selected text or, if no text is selected, the clipboard text. The text can be augmented or transformed in over seventy ways. Here are four simple examples:

The macro has been designed to provide Immediate Actions (via dedicated hot keys) for those used frequently; whereas selection from a list for those used less often.

By default, this macro is triggered using a hyper key (⌃⌥⇧⌘), plus letter T for general use. When this hot key is pressed a Prompt With List of Additions, Conversions, and Filters will appear. If one of the list options is selected, the choice will be applied to the text.

Due to the efficiency of the Keyboards Maestro Prompt With List action, any of the above Additions, Conversions, or Filters can be applied to the selected text (or clipboard text) with just a few keystrokes. However, for those that are applied frequently, there is an even faster option: direct actions applied using a designated hot key. These are referred to as Immediate Actions.

By default, ten additional hot keys are set for ten corresponding Immediate Actions.

Hyper+b

Hyper+i

Hyper+l

Hyper+v

Hyper+w

Hyper+x

Hyper+f

Hyper+s

Hyper+p

Hyper+d

If any of the above Immediate Actions are not needed, the hot keys can be removed from this macro.


SETTINGS

Refer to the comments above the three text variables local_Additions, local_Conversions, and local_Filters.


TESTED WITH

• Keyboard Maestro 11.0.3
• Sonoma 14.5 (23F79)/MacBookPro18,2
• Sonoma 14.5 (23F79)/VariableMacBookPro16,1
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445

VERSION HISTORY

( expand / collapse )

1.0 - Initial version

2.0
In the Filters section, added:
Smart Smart Single Quotes to Dumb Single Quotes
Reddit User Link to Reddit User
Quoted URL to URL

The three additions to the Filter section employ regular expressions since the Keyboard Maestro Filter action does not provide these options.

2.1 - Bug fix. Delete Past Clipboard 0 should only be executed when %SystemClipboard% <> %Variable%local_SysCb%

2.2
a) Added to local_Additions corresponding to the following hot keys: Hyper+w, x, m, and f.
b) Improved this header comment.

2.3 - No change to macro functionality. Improved this header comment.

2.4 - Changed the two Prompt With List actions to Automatic Width.

2.5
a) Removed superfluous colon ( : ) from Hyper+w.
b) Corrected typographical errors in the header comment.
c) Updated TESTED WITH information.

3.0
a) Simplified the format of local_Filters.
b) Added a Filter: KM Forum User URL to @User (example conversion: Profile - _jims - Keyboard Maestro Discourse to @_jims.

3.1
a) Added a Filter: Plain Text
b) For KM Forum User URL to @User generalized the regex search to enable more conversions (e.g., Markdown links: @_jims ).
c) For Convert Double Quotes to Dumb Quotes changed from the Filter action to the Search and Replace action because there may be times when the smart quotes do not match.
d) Corrected a typo in this comment and deleted a n/a note in the comment below: Syntax Description: SETTINGS (Additions)

4.0
a) Added Titles to the two Prompt With List actions.
b) Added an option to return the the Additions from the Filters Prompt With List.
c) Added an Addition: Quote Block
d) Modified the following Additions: Folding Section (added a horizontal rule below the text), the three KM Variables (improved the PWL labels), and KM Macro Download Annotation (improved the download annotation)
e) Improved the RegEx pattern that searches the Additions (that potentially include an Immediate Action hot key). The previous version did not function as expected for the modified Folding Section and the added Quote Block. Added a comment above the RegEx pattern to explain each RegEx element.
f) Updated the TESTED WITH section.

5.0
a) Renamed ‘Code Block’ to ‘Fenced Code Block’; added Fenced Code awk, bash, diff, html, objectivec, perl, python, ruby, xml. Also added ‘Fenced Code Syntax’.
b) Improved the descriptions for local_Additions: <mark>, <ins>, and <del>.
c) Updated the TESTED WITH.

6.0
a) Changed the macro name from Augment or Filter Text to Augment or Transform Text.
b) Transformations include the Filters and a new set: Conversions
c) The Conversions include eight conversions to unicode characters. This is done with a JXA function.
d) All actions (Additions, Conversions, and Filters) appear in a single Prompt With List.
e) Immediate Actions are no longer restricted to Additions.
f) Added three default Immediate Actions. See Hyper+s (plain text to Sans Serif Bold), Hyper+p (rich text to plain text) , and Hyper+d (all smart to dumb quotes).
g) Immediate Actions are denoted at the end of the Prompt With List items. For example, for <hk>s:ssb • Sans Serif Bold, the PWL item is: ssb Sans Serif Bold〈 s 〉
h) Added <div align="center"></div> to the Additions; added '" • Convert All Quotes (Single and Double) to Dumb Quotes to the Filters.
i) Eliminated the notification if no text is selected and the Clipboard is being used.
j) Improved the comments throughout.

7.0
a) Added a Prompt With List option to modify the macro. This makes it easier to modify the configuration.
b) Added a Prompt With List header line that displays the first 80 characters of the selected text (or if it being used, the Clipboard).
c) Displays an error if an Immediate Action hot key in repeated in the configuration.
d) Displays a dialog if no text is selected and if the Clipboard does not include text.
e) Modified the logic to significantly improve performance.


Download: Augment or Transform Text.kmmacros (151 KB)

Macro-Image


Macro-Notes
  • 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 14.5 (23F79)
  • Keyboard Maestro v11.0.3

13 Likes

In the OP, I've updated Augment or Filter Text to Version 2.0.

In the Filters section, added:

  • Smart Smart Single Quotes to Dumb Single Quotes
  • Reddit User Link to Reddit User
  • Quoted URL to URL

The three additions to the Filter section employ regular expressions since the Keyboard Maestro Filter action does not provide these options.


Note: If you previously added to local_Additions and/or local_Filters you'll likely want to make those same additions to Version 2.0.

In the OP, I've updated Augment or Filter Text to Version 2.1.

Bug fix. Delete Past Clipboard 0 should only be executed when %SystemClipboard% <> %Variable%local_SysCb%


Note: If you previously added to local_Additions and/or local_Filters you'll likely want to make those same additions to Version 2.1.

1 Like

Nice macro Jim.

There have been several threads of people asking for how to get this functionality with KM.

Thanks!

1 Like

I've updated the OP with Version 2.2 of Augment or Filter Text:

  • Added to local_Additions corresponding to the following Hot Keys: Hyper+w, x, m, and f.

  • Improved the macro header comments.

I've updated the OP of Augment or Filter Text:

Version 2.4

Changed the two Prompt With List actions to Automatic Width.

this is so awesome...if there's any way to spread this get it out there more, i def would

dual

The same key-binding (Hyper+I) has two different roles ?

Hi @varuntheestallion. Glad you like it. Thanks for the comment.

I think you just did with your positive comment. :grinning:

1 Like

Hi @ComplexPoint. Sharp eyes! Thanks for pointing out the typographical error in the forum post. I had the same typographical error in the header comment. The macro configuration was fortunately as intended: Hyper+i for italics and Hyper+l for link.

I had a minor update that I hadn't uploaded; I'll upload it now with the typo corrected. Thanks again.

1 Like

I've updated the OP with Version 2.5 of Augment or Filter Text:

  • Removed superfluous colon ( : ) from Hyper+w.

  • Corrected typographical errors in the header comment.

  • Updated TESTED WITH information.

I've updated the OP with Version 3.0 of Augment or Filter Text:

I've updated the OP with Version 3.1 of Augment or Filter Text:

  • Added a Filter: Plain Text

  • For KM Forum User URL to @User generalized the regex search to enable more conversions (e.g., Markdown links: [@_jims](https://forum.keyboardmaestro.com/u/\_jims/summary) ).

  • For Convert Double Quotes to Dumb Quotes changed from the Filter action to the Search and Replace action because there may be times when the smart quotes do not match.

  • Corrected a typo in this comment and deleted a n/a note in the comment: Syntax Description: SETTINGS (Additions)

1 Like

Hi @_jims thanks for this macro! It serves right what I need. I however am facing a problem.

It was working perfectly for a few tries. Then just now, when I trigger it, it is not detecting selected text anymore, and it is always referencing the system clipboard. Any idea what can be interfering with its normal function? Thanks!

Hi, @bash. Sorry you are having difficulty.

If I had more information, there would be a much better likelihood that I'd be able to help. Absent that information, I advise:

  • Log out of your account and then back in. In rare cases I've seen macros misbehave and the logout/login solved the problem.

  • Try using the macro within multiple apps, e.g., TextEdit, Pages, and any other text editor you might have (e.g., the built-in Stickies app).

  • If there is any chance you've modified the macro (even accidentally), I suggest that you delete it*, and then download and install a new copy of the macro.

    *If you did change any of the configuration variables in the macro, then you will want to save those values.


If the above does not solve your problem, please report back with a more detailed description of your usage and observations. I'll do my best to help you out. I've used this macro for many months on three Macs, all running different versions of macOS, and not seen the behavior you are observing.

2 Likes

Hey @_jims your message helped debug and I finally found the cause of discrepancy. I use Copy 'Em app as for history clipboard. At some point, I must have deleted some items from my history, causing a discrepancy between the KM clipboard history and Copy 'Em making them unsynced, hence the unwanted result. Thanks again for your prompt response and help. Very useful macro! Given I am in a bilingual country, French quotes vs Regular quotes (depending on the language I am using) is a life saver to quickly switch between both. Thank you!

2 Likes

I've updated the OP with Version 4.0 of Augment or Filter Text:

  • Added Titles to the two Prompt With List actions.

  • Added an option to return the the Additions from the Filters Prompt With List.

  • Added an Addition: Quote Block

  • Modified the following Additions: Folding Section (added a horizontal rule below the text), the three KM Variables (improved the PWL labels), and KM Macro Download Annotation (improved the download annotation)

  • Improved the RegEx pattern that searches the Additions (that potentially include an Immediate Action hot key). The previous version did not function as expected for the modified Folding Section and the added Quote Block. Added a comment above the RegEx pattern to explain each RegEx element.

  • Updated the TESTED WITH section.

1 Like

I've updated the OP with Version 5.0 of Augment or Filter Text:

  • Renamed ‘Code Block’ to ‘Fenced Code Block’; added Fenced Code awk, bash, diff, html, objectivec, perl, python, ruby, xml. Also added ‘Fenced Code Syntax’.

  • Improved the descriptions for local_Additions: <mark>, <ins>, and <del>.

  • Updated the TESTED WITH.

I've updated the OP with Version 6.0 of Augment or Transform Text:

  • Changed the macro name from Augment or Filter Text to Augment or Transform Text.

  • Transformations include the Filters and a new set: Conversions

  • The Conversions include eight conversions to unicode characters. This is done with a JXA function.

  • All actions (Additions, Conversions, and Filters) appear in a single Prompt With List.

  • Immediate Actions are no longer restricted to Additions.

  • Added three default Immediate Actions. See Hyper+s (plain text to Sans Serif Bold), Hyper+p (rich text to plain text) , and Hyper+d (all smart to dumb quotes).

  • Immediate Actions are denoted at the end of the Prompt With List items. For example, for <hk>s:ssb • Sans Serif Bold, the PWL item is: ssb Sans Serif Bold〈 s 〉

  • Added <div align="center"></div> to the Additions; added '" • Convert All Quotes (Single and Double) to Dumb Quotes to the Filters.

  • Eliminated the notification if no text is selected and the Clipboard is being used.

  • Improved the comments throughout.

I've updated the OP with Version 7.0 of Augment or Transform Text:

  • Added a Prompt With List option to modify the macro. This makes it easier to modify the configuration.

  • Added a Prompt With List header line that displays the first 80 characters of the selected text (or if it being used, the Clipboard).

  • Displays an error if an Immediate Action hot key in repeated in the configuration.

  • Displays a dialog if no text is selected and if the Clipboard does not include text.

  • Modified the logic to significantly improve performance.