- Basic text expansion
- When to use copy vs typing
- Limiting to applications
- Basic variables
Basic Text Expansion
The basic text expansion macro looks like the macro on the right.
- It is triggered when a string is typed, in this case
- It has a single action, Insert text by Typing, containing the text to be typed, in this case
git pull; make clean; make -j 8.
Thats all there is to it. Nice and simple.
;gma anywhere and Keyboard Maestro makes the replacement.
Insert text by typing vs pasting
Almost all the time, Insert text by typing is the right way to go. Its fast enough and does not affect the system clipboard. However, for long strings, typing may be too slow.
In these rare cases, Insert text by pasting is way faster. But you need to add another step to the macro. Add a Set Clipboard to Past Clipboard step after the paste to reset the clipboard back by 1 in Keyboard Maestro’s history. (Thanks to @TheBaronHimSelf for this tip.)
Limit To Application
Many of my snippets apply only to specific applications. To limit snippets to an application (or set of them), I create a new Group and make it available in a selected list of applications.
The snippets in this group only expand in Xcode.
Keyboard Maestro has many of the same variables and abilities as TextExpander (and a whole bunch more, of course), including
- Position Cursor after typing
- The current clipboard
So, for example, to create a Markdown Link using a URL on the clipboard and place the caret (the text insertion cursor) in the description area, I can use my
Or to create a date heading in an Assembly Note, I can use my
You can format the date any way you like, of course.
To see what variables are available, click the Insert Token dropdown on the right of the action panel. As you can see, there is a huge number available.
I have managed to replace the majority of my TextExpander snippets using the basic text expansion macro described here, and it’s working great.
Next to do these with sounds and with more advanced abilities.
Hope this helps.
Follow the author as @hiltmon on Twitter.