Customizing iWork ’09: Inserting current date

Posted by Pierre Igot in: Pages
April 22nd, 2010 • 3:36 pm

Long-time Betalogue readers know that I am an enthusiastic user of Spell Catcher X. Its multilingual spell checking and automatic text entry features are invaluable in my daily work and I totally depend on them for sustaining my high level of productivity.

However, while it already does a lot, and does more with each new release, thanks to the skills and responsiveness of its developer Evan Gross, it cannot do everything I need, in part simply because of the way it works, i.e. via Mac OS X’s Input menu.

Fortunately, I have recently discovered that I can supplement Spell Catcher’s features using Keyboard Maestro. Keyboard Maestro can do things that Spell Catcher cannot, and can thus come to my rescue when I want something that falls outside Spell Catcher’s field of expertise. (And the two are perfectly compatible with each other, of course.)

I’ve recently posted about using Keyboard Maestro to automatically insert specific French phrases such as the French equivalents of “19th Century,” “20th Century,” and so on.

Essentially, such macros mimic what one would normally do manually, i.e. they insert the text as plain characters and then go back and select the appropriate bits and apply specific types of formatting to them (small caps, superscript, etc.).

Of course, Spell Catcher has the capability to insert the text. (It can even do things that Keyboard Maestro cannot, i.e. insert a different string for the same abbreviation depending on which language you are typing in, which is why it is better than Keyboard Maestro for automatic text insertion that does not involve formatting options.) And it can also move the insertion point around by mimicking the use of the cursor keys, like Keyboard Maestro.

But it cannot automatically select menu items, in order to apply formatting options.

Another thing that Spell Catcher cannot do is work well within tables, whether it’s in Pages ’09 or in Numbers ’09. Because Mac OS X intercepts the Tab keystroke that is used to jump from table cell to table cell, Spell Catcher cannot detect it and therefore cannot know that you’ve changed cells and started a new word. And so you cannot use Spell Catcher glossary abbreviations (for automatic text insertion) immediately after entering a new table cell. You first have to type a word separator, such as a space.

This is particularly a problem for me for entering dates in table cells. I have a universal glossary abbreviation in Spell Catcher that automatically inserts the current date in the yyyy-mm-dd format when I type “sd” (as in ”small date”) followed by a word separator. But when I enter a new table cell with the Tab key and just want to insert the current date there, it does not work, because Spell Catcher does “know” that I have changed cells and started a new word, so it still thinks that “sd” is part of the last word that I typed in the previous cell (and of course also plays an alert to indicate a spelling mistake).

That’s where Keyboard Maestro comes to the rescue. Like Spell Catcher, Keyboard Maestro is able to automatically insert the current date in a variety of formats (using the action “Insert Text” and the date options in the “Insert Token” menu). But unlike Spell Catcher, Keyboard Maestro does not require a word separator to trigger the macro. It can detect any specific text string and automatically replace it with the date even without an additional keystroke.

I can even use the same “sd” abbreviation as a trigger, so that I don’t have to learn a different one. I just use the following macro:

Small Date macro

This automatically detects when I type “sd” anywhere (including in table cells that I have entered by pressing Tab) and replaces it with the date in the format I desire.

I should note that, by default, Keyboard Maestro only supports three date formats, called “Long,” “Short,” and “Number,” which are actually equivalent to the “Full,” “Long,” and “Short” date formats in System Preferences, under “Language & Text.” The terminology is confusing, and I suggested to Keyboard Maestro’s developer Peter Lewis that he should change it to match the one used in System Preferences.

He should also add the fourth date format option offered in System Preferences, which is called “Medium.” On my system, I have customized this option so that it displays the date in the yyyy-mm-dd format that I want, because the “Short” option is too short for me and only uses the last two digits of the year number.

Such an option is not available in Keyboard Maestro using the “Insert Token” menu, but, as you can see in the macro above, it’s easy to work around this limitation by simply adding “20” before the short date. This works just as well, and will continue to do so until 2100, by which time our descendants will probably no longer use keyboards anyway.

That said, Peter also pointed out to me that you can use the “ICU Date Time” token in Keyboard Maestro, which effectively lets you choose exactly which part of the date or time you want to insert using the ICU date format options. This can also be used to produce the yyyy-mm-dd format, although it’s a bit more complicated.

I cannot count the number of times I use this small date format on my computer during the day (in file names, in table cells, etc.). Now, thanks to both Spell Catcher and Keyboard Maestro, I can use a small universal abbreviation to insert it pretty much anywhere I want to.

(Before I started using Keyboard Maestro, I would still use my “sd” SCX abbreviation in Numbers and Pages inside tables. But I would have to insert a space before the date first and then type a space after. Fortunately, Numbers was smart enough to automatically erase these superfluous spaces after I exited the cell if the number format for the cell was a date format, so this wasn’t too big of a problem. But it’s still more elegant to be able to type “sd” without any spaces and have KM automatically replace it with the appropriate date. The only problem is, of course, that I have to unlearn the use of the Space bar as the trigger to insert the date in place of the abbreviation—although I suppose I could also instruct KM to require “sd ” with a space as a trigger and delete the extra space in the macro.)

Comments are closed.