Deprecated: Return type of I::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 62

Deprecated: Return type of I::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 91

Deprecated: Return type of I::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 71

Deprecated: Return type of I::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 101

Deprecated: Return type of I::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 53

Deprecated: Return type of Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/collection.php on line 80

Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /home/public/kirby/toolkit/lib/url.php on line 135
One Tap Less | Replace Ranges in Drafts

Replace Ranges in Drafts


Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Freshly updated to version 4.6, Drafts brings plenty of bug fixes and new features, of which my favorites are the Trash, a limbo where your notes go temporarily after deletion, and the new replaceRange url scheme and the perks that come with it to change selections or any stretch of text.

Two years ago I covered this feature for 1Writer and the first thing to do is to replicate most of those actions for Drafts now that it can replace selections. An example on how to educate text (apply smart quotes and smart dashes) with TextTool:

Educate in TextTool

Applies smart quotes and smart dashes

Get Action

And here’s an action to lookup a word in Terminology and replace it with a synonym:

Replace in Terminology

Searches selected text in Terminology and replaces it in the original draft with the word picked in the latter.

Get Action

If you deal with a lot of short links, you probably already stumbled upon Clean Links and this action sends a selected url to the app and returns with the original url:

Clean Link

Sends selected short url to Clean Links and replaces it in the original draft for the original url.

Get Action

Here's a great app I say very little about since it is not a niche I'm into – Knock, knock, Dr. Drang – but MathX can run formulas and return the results from its url scheme.

Calculate with MathX

Sends selected formula to MathX and replaces it in the original draft for the result.

Get Action

I use Blink all the time to search for apps1 and generate affiliate links. This action by Greg Pierce searches for your selection and returns the link for the app you choose:

Blink Replace

Search for selected text in Blink, returning to Drafts replacing that text with the link generated by Blink.

Get Action

Need to know basis

The replaceRange url scheme pairs very well with the [[selection]] template tag, however, if you don’t have any text selected, the tag sends the entire draft, meanwhile the new template tags, [[selection_start]] and [[selection_length]], still return your cursor position and zero, respectively, in this case. Therefore, when the replaceRange action is triggered, it will inject the text in the current cursor position instead of replacing the whole draft.

I built a helper action that normalizes this behavior with 2 new tags: sel_start and sel_length, I suggest you to save this action separately and add to whatever action you need with the Include Action step:

Fix Selection

[[selection]] is perfect with the new replaceRange, but when you don’t select any text the tag sends the whole draft, meanwhile the selection_start and selection_length tags still return based on cursor position. This action normalizes the behavior with two new tags, sel_start and sel_length.

Get Action

This is useful if you process your entire draft often, specially for TextTool, but I also want you to get used to the Include Action step as we may see more helper functions around here.

Overall this is a great new resource for Drafts and it is a shame not many apps return values within the x-success response2 to extract the most of this feature. I can imagine you’ll find a nice integration with this new scheme and the Run Workflow.

Besides the Trash and replaceRange url scheme, Drafts 4.6 also brings Box.com integration, tag helpers (to aid you build actions) and hundreds of action icons to choose from. It's a great reason to update the app today.


  1. Often preferring it over the App Store itself 

  2. And some supposed to work according to their documentation simply don’t.