Simple shortcut replacement

This action scans the current draft for shortcut abbreviations and expands them into larger phrases of text that you define.

Action Directory link:

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


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 (-).

  - 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.


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 for more information.



  • Allow shortcutTag to be defined in first Script step. Contributed by @MrBlaschke.


  • Add support for Drafts tags. Contributed by @pdavidsonreiber.


This version changes the shortcuts from comma separated values (CSV) to YAML. To upgrade your existing shortcuts:

.hw,Hello World
.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.

thanks, this is great!! is it possible to extend this to support multiple “shortcut drafts”?
I’d like to use this for message templates with different replacements for the shortcuts, e.g. a name or a phone number and change them accoridng to who i’ll send the message - that would be awesome!

1 Like

This is brilliant!

I’m bound to forget to run the script, so I added it as an ‘Insert Action’ step on my most commonly used actions (like Mail, Copy and Share).


1 Like

Yes sorry i wanted to use that with multiple „shortcuts“ drafts but which can Contain the same shortcut.

Lets say one colleague is mike with mail
My shortcuts would be
-name, mike
-mail, mike@company. com

Lets assume ive another colleague nick, then i have the shortcuts would be:
-name, nick
-mail, nick@company. com

If i have a Message template which uses these shortcuts this would just insert the same shortcuts everytime and i cant decide which contact data i Want to insert right?

1 Like

It won’t work for that use case. It will use the first replacement it finds. Let me think if there’s a way to accomplish it.

1 Like

maybe “prompt” is an option - to let the user choose from which draft the shortcuts shall be used?

Trying to think what would be the most flexible way to store the data. A separate shortcuts draft for each contact might be cumbersome.

1 Like

Hm depends on how many contacts you want to use in that usecase. In my case that won’t be more than 10 but i can see the point… I think there are better ways to share contact data e.g. with vcf exporting and drafts is no crm tool :slight_smile:
In my opinion the workflow could be like that:

  1. I select the message template I want to use
  2. I duplicate that drafts (or just the draft body if there is a heading)
  3. I start your replacement script which
    3.1 asks me in a prompt from which “shortcuts” tagged draft i want to insert the data (maybe the drafts should contain a title line with the name of the contact…
    3.2 inserts all the shortcuts
  4. i copy the draft or use another extension (Mail, message) to finally send the message to the person i want

of course all of that could be in one simple action which internally calls different actions.

I experienced problems with the script when the draft doesnt contain all the shortcuts i defined in the “shortcuts” tagged draft. Would be awesome if I wont need all the shortcuts there.

Thank you very much!

1 Like

What problem are you having when the drafts doesn’t have all the shortcuts?

This is my error

Sorry. I had that fixed but forgot to update. Should be good now.


Yes it is :slight_smile: really nice thank you!

1 Like

I’ve updated the action to include multiple choice abbreviations.

If you’re using an older version and want to update you’ll need to tweak your shortcuts.


@dchar this is just awesome work! Thank you!
I’ve just a single problem, the draft with the shortcuts was placed in the archive and I ran the action on a draft in my inbox. It tells me that no shortcuts are defined. It’s confusing for me because the shortcuts I define dont need to be in my inbox but the current draft is in the inbox of course? Would be great if you can change and update the action to search through the archive, too. I made a temporary workaround to move the draft to my archive and then back to the inbox after the shortcuts action executed :slight_smile:

Additionally, I wanted to say that I have sometimes “problems” because I need placeholders for some Replacements I cant save as shortcut, like a name of a person who just contacted me and doesnt exist in my shortcuts. The drafts template parser is great for sth. like this. I just use the shortcut replacement and the template parser together in an action with just two “include Action” steps.

Great work again dchar!

1 Like

@FlohGro I updated the action so that it finds shortcuts in the archive directory too.

1 Like

Can you please check the script. I tried your multiple choice shortcut and got an error:

Script step completed.
Script Error: YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key     at line 24, column 1:

Line number: undefined, Column undefined

It’s likely an issue with the draft where you define the shortcuts. Can you share that — if it doesn’t have any sensitive data.

I actually posted your code from the website:


  • Montgomery, Alabama
  • Juneau, Alaska
  • Phoenix, Arizona
  • Little Rock, Arkansas
  • Sacramento, California
  • Denver, Colorado

The error occurs when I run the action on a draft that contains a single word


Please disregard. You were right. I had to Digg through some other shortcuts and found that there is a possible error with a shortcuts that contains long sentences.

Can you update the example with the longphrase? There is a missing quotation mark at the end.

Should be:

.longphrase: "
This is a long phrase
that is split across
multiple lines."