This action scans the current draft for shortcut abbreviations and expands them into larger phrases of text that you define.
Updated: Added multiple choice abbreviations. Switched shortcut syntax to YAML.
Action Directory link: https://actions.getdrafts.com/a/1IS
Drafts Forum: Simple shortcut replacement
Create a draft with a tag
shortcuts and add abbreviations you want replaced with longer phrases of text. Put each abbreviation and phrase on one line separated by a colon.
.hw: Hello World .pi: 3.14159265358979323846 .ty: Thank you for your assistance in resolving this matter.
Type out abbreviations as you write your draft.
Programmers start by saying, ".hw" pi to 20 places is .pi .ty
Then run the shortcut action to expand the abbreviations.
Programmers start by saying, "Hello World" pi to 20 places is 3.14159265358979323846 Thank you for your assistance in resolving this matter.
You can run the shortcut action once when you’re done or periodically while you’re typing.
The “Include Action” step can be used to automatically run the shortcut action as part of other actions, like before sending a text or email.
Defining Long Phrases
In the shortcuts draft, long phrases can be split across multiple lines with single or double quotes:
.longphrase: " This is a long phrase that is split across multiple lines.
Line endings and leading whitespace will be ignored when
.longphrase is replaced:
This is a long phrase that is split across multiple lines.
Multiline phrases can be entered in “block style” by starting with a pipe character (
|) and indenting each line with two spaces:
.multi: | Ths is a multiple line phrase defined in block style
Line endings will be preserved when
.multi is replaced:
Ths is a multiple line phrase defined in block style
The shortcut syntax is YAML, so there are lots of options for defining multiple line strings.
Multiple Choice Abbreviations
Abbreviations can be defined with a list of possible choices and the shortcut action will display a prompt to select one of the phrases for expansion. This is useful for email or message templates that are sent frequently.
To define a multiple choice abbreviation, place each phrase on a separate line indented with two spaces and a dash (
.capitals: - Montgomery, Alabama - Juneau, Alaska - Phoenix, Arizona - Little Rock, Arkansas - Sacramento, California - Denver, Colorado ...
The shortcut action will look for abbreviations in all drafts with the
shortcuts tag. This allows shortcuts to be saved in different drafts for better organization or for sharing.
Shortcuts are defined using basic YAML. Advanced users can take advantage of the YAML syntax especially for defining multiple line strings. Refer to a YAML tutorial like https://yaml-multiline.info/ for more information.
This version changes the shortcuts from comma separated values (CSV) to YAML. To upgrade your existing shortcuts:
.hw,Hello World .pi,3.14159265358979323846 .ty,Thank you.
Replace the comma (
,) with a colon and a single space (
:) as shown below:
.hw: Hello World .pi: 3.14159265358979323846 .ty: Thank you.