MACRO: Augment or Filter Text, v5.0

Augment or Filter Text


PURPOSE

This macro is used to modify selected text or the clipboard text, if no text is selected. The text can be augmented* or filtered** in many ways. Here are three simple examples:

The macro has been designed to provide immediate additions (via dedicated hot keys) for those used frequently; whereas selection from two lists*** for those used less often.

*text Additions can easily be added to the 46 initially configured

**text Filters can be easily added to the 21 initially configured

***there is one Keyboard Maestro Prompt For List for text additions and one list for text filters

DEMONSTRATION

The following video includes four quick demonstrations of this macro: https://youtu.be/Yvnwopo6fio

SETTINGS / HOT KEYS

By default, this macro is triggered using a hyper key (⌃⌥⇧⌘), plus letter T for general use. When this hot key is pressed the a text Additions Prompt With List will appear. If one of the 37 default options is selected, the choice will be immediately applied to the text. Alternatively, if /+<return> is typed the Skip below Additions; continue to text Filters choice will dismiss the text Additions and a second Prompt With List with text Filters will appear. Here one of the 21 Filter choices can be similarly applied.

Due to the efficiency of the Keyboards Maestro Prompt With List action, any of the above 67 (46+21) text transformations can be applied to selected text with just a few keystrokes. However, for Additions that are applied frequently, there is an even better option: immediate addition with a designated hot key (a.k.a. Immediate Additions). By default, eight additional hot keys are set for eight corresponding Immediate Additions.

(In the following selected_text will be augmented with the indicated additional text.)

Hyper+b

Hyper+i

Hyper+l

Hyper+v

Hyper+w

Hyper+x

Hyper+m

Hyper+f

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

Refer to the comments above the two text variables local_Additions and local_Filters for more information about adding Additions, Filters, or Immediate Additions hot keys–like the eight indicated above.

TESTED WITH

• Keyboard Maestro 11.0.1
• Sonoma beta 14.2 (23C5030f)/MacBookPro16,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.


Download: Augment or Filter Text.kmmacros (114 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.2 (23C5030f) PRE-RELEASE SEED SOFTWARE
  • Keyboard Maestro v11.0.1
11 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.