July 28, 2010 at 8:11 AM by Dr. Drang
There was a recent discussion on the TextMate mailing list about automating the creation of TextMate footnotes. Stephan Hugel, who started the discussion, likes having his footnote text at the bottom of the document and wanted some command/snippet/macro system that would do most of the fiddle work for him. I pointed out my Markdown reference link system for TextMate and suggested how it could be modified to do what he wanted. You can read about it by following the discussion thread. I won’t recapitulate it here, because that particular way of doing footnotes isn’t to my taste. I do, however, have a couple of footnote-making automations that I’d like to share.
First, you should recognize that footnotes aren’t a part of the official Gruber Markdown. They are, however, included in several Markdown variants/extensions, including Michel Fortin’s PHP Markdown Extra and Fletcher Penney’s MultiMarkdown.
Here’s an example of footnote syntax:
* First, it's kind of backwards. You do the footnote text first, then set the position of the marker. I find this perfectly natural, but you may think it's weird. * Second, it replaces whatever was on your clipboard with the marker. This doesn't bother me because I use [Jumpcut], a [multi-clipboard tool] that saves the last 40 text clippings. If you don't use a utility like Jumpcut, you'll find this behavior *really* annoying.[^multiclip] [^multiclip]: But you really should be using a multi-clipboard tool. It makes working with text so much easier.
The footnote marker is placed where the
[^marker] is, and the text of the footnote is the paragraph that starts with
[^marker]:. The footnote text can go anywhere in the document; it can even be intermixed with reference-style links down at the bottom, although in my opinion that makes for an unreadable mess. I tend to put my footnote text just after the paragraph with the corresponding marker.
To semi-automate the insertion of footnotes, I use a snippet and a macro, which you can download in this zipped TextMate bundle. The source code of the snippet is just
The marker (default value:
marker) is the first tab stop and the footnote text (default value:
Footnote) is the second. Tabbing a third time puts the cursor at the end bracket of the marker, which is where the macro expects to start. The Tab Trigger for this snippet is, in a nod to LaTeX, fn.
The macro is similarly trivial. It selects the text from the current position (just after the marker’s end bracket if you invoke it right after the snippet) to the beginning of the line (just before the marker’s start bracket), copies it to the clipboard, and sets the cursor at the beginning of the footnote paragraph. The marker is now on the clipboard, ready to be pasted wherever I want to put it. The Key Equivalent for this macro is ⌃⌥⌘F.
You should note two things about this method of doing footnotes:
- First, it’s kind of backwards. You do the footnote text first, then set the position of the marker. I find this perfectly natural, but you may think it’s weird.
- Second, it replaces whatever was on your clipboard with the marker. This doesn’t bother me because I use Jumpcut, a multi-clipboard tool that saves the last 40 text clippings. If you don’t use a utility like Jumpcut, you’ll find the loss of your previous clipboard really annoying.1
If these caveats don’t bother you, install the Markdown Footnotes bundle and give it a try. If you do a lot of footnotes, it can save you some time.
But you really should be using a multi-clipboard tool. It makes working with text so much easier. ↩