Match Symbols, Brackets with one hotkey

To provide a full-blown example of entering matching brackets using the KM “Typed String” Trigger (AKA "Text Expansion), I have built and published the following macro:

###MACRO: Enter Matching Bracket Using Text Expansion Trigger [Example]

Anyone potentially interested might give it a test drive.
Please consider this:

  • It is very fast (<<1 sec), so fast that I can just keep typing
  • It is easy to configure to suit your needs:
    • Change/eliminate the prefix of semicolon (;)
    • Add more brackets to be handled

All feedback (pro and con) is welcome. Please post in the above topic where the macro is posted.

3 Likes

The macro will trigger for both < and <!, assuming you do not type anything in the macros (typing something will kill the typed string buffer).

At that point, you will need to deal with the Last Bracket as appropriate.

I just tap whichever bracket (open or close bracket) or quote I want twice and KM does the rest.
I hope this works. I haven't tried posting a macro before
Brackets.kmmacros (2.7 KB)

Emyr

In case anyone wants to experiment with bracket-matching in JavaScript for Automation,
or in Applescript:

http://rosettacode.org/wiki/Balanced_brackets#JavaScript

http://rosettacode.org/wiki/Balanced_brackets#AppleScript

1 Like