This is essentially just the README from the github project I link to at the end, so you might want to skip straight to that instead.

This might be a particularly esoteric problem, but bear with me. I have a particular hatred of typing numbers for lists, for example bullet points, SKU codes, etc. It's horrible having to type

1 ~blah, blah~
2 ~blah, blah~
3 ~blah, blah~
....
99 ~blah, blah~

Ick.

It gets even worse if you're typing Roman numerals, or formatted SKU codes, or whatnot.

Autogenerating list items is a feature absent in most simple editors, and even full-featured ones can have trouble with complex sequence rules. This Snippet gets round this by giving access to a persistent sequence that can be called from a triplet of keyboard triggers, and easily extended with simple Ruby classes to cope with the most bizarrely formatted numbers.

Installation

First, you'll need the uuid gem installed

$ sudo gem install uuid

After that, download the zip from github. Import Sequence.textexpander into TextExpander. Move the rest of the files into ~/Tools/TextExpanderScripts/textexpander-sequence/ or update the Snippets to point to wherever you've put them.

Usage

In any application type:

  • "seqq" to start a new sequence and insert its first element.
  • "sdd" to insert the next item in the sequence.
  • "saa" to insert the previous item in the sequence.

Reuse

By default, the Snippet sets up a single sequence. To set up more, copy the group in TextExpander and change the first argument to sequence_runner.rb:

#!/bin/bash
ruby ~/Tools/TextExpanderScripts/textexpander-sequence/sequence_runner.rb OTHER_SEQUENCE restart 

Sequence Formatting

A Formatter object is used to transform the sequence before output. The default is just to print out the number with no transformation. There are currently two sample Formatters:

  • RomanNumberalFormatter - does what it says on the tin
  • SprintfFormatter - takes a printf formatted string and passes the sequence element through for output.

To change the formatter you'll have to change the constructor to Sequence in sequence_runner.rb.

sequence = Sequence.new(ARGV[0], RomanNumeralFormatter.new)

...will generate...

I One
II Two
III Three IV Four

As I say, a very specific scratch for a very specific itch, but I hope you find it useful. You can download all the files from textexpander-sequence on github

Leave a Comment

You can use the Markdown for links, strong, and emphasis tags in your comment.

From Nov 30th, 2009.

This article is tagged with TextExpander, projects, and ruby.

Commenting is currently enabled. There are 0 comments so far.

Related Articles.

On Charles Arthur's P2P moral dilemma.

Batch converting doc files to pdf on OS X

The Beautiful Game.

Pollock: a gem to help with html wireframing

has_web_fallback