An updated Increment Templated Service

The Increment Templated Service is one I wrote a couple of years ago and have found more useful over time than I thought it would be. It’s had some updates since then, and now covers a few more use cases.

Usage

To use it, you simply write some text with “##x,y##” in it, where x is the starting number and y is the ending number for the sequence. For example:

This is part ##10,13## of 20.

When that text is selected and the service is run, you get:

This is part 10 of 20.
This is part 11 of 20.
This is part 12 of 20.
This is part 13 of 20.

You can also insert repeats or modified repeats of the current index, so the text:

##0,4## This is list item ##+1##

Will take the current index and add 1 to it in the place of the modifier:

0. This is list item 1
1. This is list item 2
2. This is list item 3
3. This is list item 4
4. This is list item 5

Improvements

First, it maintains indentation better now, so you can use it in more situations.

Just to scratch my own itch for a one-time need, I also added the ability to left-pad numbers in the template sequence.

You can now pad numbers in the sequence by adding leading zeroes. The result will pad to the length of the starting number or modifier. For example:

##001,5##. List item ##00##

Will produce:

001. List item 01
002. List item 02
003. List item 03
004. List item 04
005. List item 05

You can also exclude the start and end modifiers by prefixing them with “?:”, e.g.:

?:##0,4## This is item ##1##

Will produce:

 This is item 1
 This is item 2
 This is item 3
 This is item 4
 This is item 5

Which allows you to repeat a sequence a certain number of times but display only the modified token outputs.

Download

Increment Templated Service v2

Repeats a selected block of text a specified number of times, replacing placeholders with the count of the current item with variable start and end numbers.

Published 07/01/12.

Updated 02/10/14. Changelog

DonateMore info…

Brett Terpstra

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff on Twitter, GitHub, and Mastodon. Keep up with this blog by subscribing in your favorite news reader.

This content is supported by readers like you.

Join the conversation