This action scans the current draft for shortcut abbreviations and expands them into larger phrases of text that you define.
Action Directory link: https://actions.getdrafts.com/a/1IS
Drafts Forum: Simple shortcut replacement
Quick Start
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
...
Drafts Template Tags
Shortcuts can include tags that will be expanded by Draftsâ template engine. Some useful tags are [[date]]
and [[template|path]]
.
Tags must be enclosed within double quotes when defining a shortcut as shown below.
.date: "[[date]]"
.location: "[[latitiude]] [[longitude]]"
.disclaimer: "[[template|corporate-disclaimer.txt]]"
Organizing Shortcuts
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.
YAML
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.
Changes
1.03
- Allow
shortcutTag
to be defined in first Script step. Contributed by @MrBlaschke.
1.02
- Add support for Drafts tags. Contributed by @pdavidsonreiber.
1.01
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.