Simple shortcut replacement


#1

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

Action Directory link: https://actions.getdrafts.com/a/1FE

Defining shortcuts

Create a draft with a tag shortcuts and add some abbreviations you want expanded into larger phrases of text. Put each abbreviation and phrase on one line separated by a comma.

.hw,Hello World
.pi,3.14159265358979323846

.ty,Thank you for your assistance in resolving this matter.

Multiline phrases can be enclosed in double quotes.

.multiline,"
Line 1
Line 2
Line 3"

.reg,"
Warmest Regards,
Clark Griswold"

.li,"
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua..."

Using shortcuts

Type out the abbreviations as you write your draft.

Programmers say ".hw"

pi to 20 places is .pi

Insert random text with

.li

Run the shortcut action to expand the abbreviations. You can run the shortcut action once when you’re done or periodically while you’re typing.

Programmers say "Hello World"

pi to 20 places is 3.14159265358979323846

Insert random text with

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...

#2

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!


#3

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

Thanks.


#4

That should already work. You should be able to create multiple shortcut drafts and the action will use all of them.

I’ll update the documentation to make that clear.


#5

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 mike@company.com
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?


#6

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.


#7

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


#8

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


#9

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!


#10

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


#11

This is my error


#12

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


#13

Yes it is :slight_smile: really nice thank you!