Sublime Text 2 Markdown Footnote Goodness

As I mentioned previously, I’ve converted the little python link gathering doodad I did into a command for Sublime Text 2. But, because I am an aggressive footnoter, I decided I wanted some convenience functions for footnotes.1 And so I made some. Hooray.

The results are up at my fork of the MarkdownEditing Package. The furnished commands are pretty simple.

  • Insert footnote. Press ^⌘6 2 to insert a footnote after the current word.3
  • Gather missing footnotes. ⌘⌥⇧g will look for footnote markers that aren’t currently defined and add markers at the bottom of your document. Not so useful by itself, I admit, but useful in conjunction with the next:
  • Switch to/from footnote definition. ^⌥6 will switch between the text of a footnote and its references. So: if my cursor is in a footnote, and I press ^⌥6, ST2 will select the references to the footnote in the body text. If my cursor is in a body paragraph, ^⌥6will identify the next footnote reference and take me to its text.
  • Sort footnotes. If you saw this post initially, you saw that my footnotes were out of order. Inserting a new footnote before an existing footnote will result in the notes being added out of order, and at least in the flavor of Markdown I’m using,4 this results in sorting oddities. (So: in the previous version of the post, the reference to footnote 4 came before footnote 1, and but footnote 1 came first in the ol at the bottom of the page.) Now, ⌘^s will sort the footnotes in the order in which they appear in the document. This affects the sorting of the ol, which in turn corrects the problem with marker ordering.
  • Magic footnotes. ^6 is a magic command that combines most of these commands. It does the following:

    • If the current selection is in the text of a footnote, it moves the cursor to the corresponding reference(s).
    • If the current selection is in a footnote reference, it moves the cursor to the corresponding footnote text.
    • If the current selection is neither (i.e., in the main text), it creates a new footnote.

Between these, this makes it really easy to go back and forth from footnotes to text. When I need to write a footnote, ^6 will insert a new footnote, thusly.5 Easy as can be.

  1. Obviously—well, I think obviously—core Markdown doesn’t provide syntax for footnotes, and so this will only work with a flavor of Markdown that does. 

  2. 6 because shift+6 is ^, the Multimarkdown syntax for a footnote. 

  3. This works by scanning the current file for Multimarkdown footnote markers, identifying those that are numeric, and providing the next integer—so you shouldn’t have any marker collisions. 

  4. Python Markdown via Hyde, which, let’s be frank—who knows what madness lies within. 

  5. And when I’m done writing the footnote text, ^6 will take me back to the top.