macotron.snippets
Keep text snippets under short abbreviations. With expansion on, typing an abbreviation in any app replaces it with the snippet.
macotron.snippets.set(";omw", "On my way!");
macotron.snippets.set(";sig", "Best,\nAda");
macotron.snippets.setExpansionEnabled(true);
Managing snippets
Snippets live in memory only. Set them when your plugin loads.
set(abbr: string, body: string): void
Adds a snippet, or replaces the body of an existing one.
remove(abbr: string): void
Deletes a snippet. Does nothing for an unknown abbreviation.
list(): Array<{ abbr: string; body: string }>
Every snippet, sorted by abbreviation.
insert(abbr: string): boolean
Puts the snippet's body on the clipboard, replacing what was there. It does not paste. Does nothing for an unknown abbreviation.
The current build returns undefined from insert, not a boolean. Check that the abbreviation is in list() if you need to know.
Expansion
setExpansionEnabled(enabled: boolean): boolean
Turns expansion on or off. Returns whether expansion is on afterwards, so false after asking to turn it on means the keyboard tap cannot be installed. That usually means Macotron lacks Input Monitoring or Accessibility permission.
While expansion is on, Macotron watches what you type. When the last characters typed match an abbreviation, it deletes the abbreviation with Backspace and pastes the body with Command-V. If more than one abbreviation matches, the longest wins. After a short pause it puts the previous clipboard text back; anything else that was on the clipboard, such as an image, is lost.
Space, Return, Tab, Escape, and any key pressed with Command, Control or Option clear what has been typed so far. Only plain ASCII characters count, so an abbreviation that contains other characters never expands.
An abbreviation expands as soon as it is typed, even in the middle of a word: omw would fire inside nomwhere. Start abbreviations with a character you do not otherwise type, such as ;.
isExpansionEnabled(): boolean
Whether expansion is on.
See also
- macotron.clipboard for the clipboard itself.
- macotron.launcher to list snippets as launcher rows.
- The
snippets.jsplugin.