Why I use Sublime Text

I wrote my first few videos in Microsoft Word but it seared my eyeballs and only allowed me to open one document at a time. I generally have two documents for each video: a collection of notes and a script. The notes are useless if I can't reference them quickly. Hence, Sublime Text. It lets me open many documents at once, and view two side-by-side. Unlike Word, Sublime Text also starts up in less than a second which is very important to me as a Hotline Miami fan.

That's why I started using Sublime Text, but I have found a ton of uses for it and have now automated most of the annoying things I have to do with scripts, namely footnotes and converting the text to nice HTML for publishing. Sublime Text has plugin functionality and plugins are very easy to write, so I can make it do whatever I want without getting into the time-consuming process of "real" programming. I kind of hate Python but it's hard to resist its convenience.


Plugins

MarkdownEditing

MarkdownEditing is an extension of Markdown that adds some custom tags for editors. I use them for various purposes without a fixed system. Sometimes I note down videos I want to reference, or a description of some visual I want to create. Sometimes I use them to mark the end of a voiceover session so I can find my spot next time. Sometimes I use them for their intended purposes. Check out any of my scripts for a demonstration.

MarkdownEditing also handles to-do lists which I find quite nice when I'm reviewing WIP renders of videos and want to track problems and fixes in the video edit. They are also good if I'm going into a script with many topics I want to cover. This reads like an ad for to-do lists.


Footnotelet

MarkdownEditing isn't perfect. It has rudimentary footnote support but I need a system that can handle note numbering consistently. I wanted a plugin that could insert new notes between old ones, while keeping them numbered in order of appearance. This was a big problem with Pay to Win 2, where I expanded many parts of the script after finishing the first draft. I also just don't like the standard Markdown syntax for footnotes, so I made my own thing.

Footnotelet handles footnotes in a way that works for me. Ctrl+Alt+[ adds a note at the cursor position, and renumbers existing ones if necessary. If I select an existing note and press Ctrl+Alt+], every instance of the selected note will be deleted. When I want to add an instance of an existing note, I still have to number it manually.

Download!

In Sublime Text, click on Preferences > Browse Packages..., make a new folder called "footnotelet" and extract the files there.


Regex Applicator

I use a bunch of regular expressions to convert documents from Markdown to HTML. There are plenty of existing conversion tools, but I wanted everything to work with the existing CSS on my site, and with some of the niche MarkdownEditing features. With the Regex Applicator, I can use any syntax I want if it can be captured with a regular expression.

There are two parts: a Python script that carries out the conversion, and a JSON file called regex_pairs that contains pairs of regex expressions to select Markdown syntax, strip the content from it, and insert that content into new HTML syntax. For example:

{ "name": "{== comment ==}", "search": "\\{\\={2}([\\s\\S]*?)\\={2}\\}", "substitution": "<span class=\"hilite\">{==\\g<1>==}</span>", "flags": "M"}, { "name": "{++ addition ++}", "search": "\\{\\+{2}([\\s\\S]*?)\\+{2}\\}", "substitution": "<span class=\"addit\">{++\\g<1>++}</span>", "flags": "M"}, { "name": "{-- removal --}", "search": "\\{-{2}([\\s\\S]*?)-{2}\\}", "substitution": "<span class=\"remit\">{--\\g<1>--}</span>", "flags": "M"},

I was very happy with this solution because it makes the plugin completely generic. It doesn't "have" to be a Markdown to HTML converter, it just applies any number of regular expressions to an input file and produces an output.

The sublime-settings file for the plugin also lets you set any syntax for the output file, specify a custom JSON file, and include custom comments in the converted file (any Python code that evaluates to a string works!)

Download! Updated 08-2024.

In Sublime Text, click on Preferences > Browse Packages..., make a new folder called "regex-applicator" and extract the files there.


Snippets and XML Topic Maps

Justifying and explaining the use of topic maps is way beyond the scope of this page, but I am using a topic map to track some game releases for a future project. XTM is a flexible-enough format that I can connect games in, for example, a sequel relationship; I can connect people to games in a developer relationship; and I can keep track of game files on my PC. The project in question involves a lot of secondary material like demos, articles, and manuals so keeping track of the files is a genuine problem.

The XTM format, being a subspecies of XML, is very easy to parse in a web browser. I am interested in making a kind of "atlas" to go along with certain projects, and XTM is both a great tool for organization and a great format for converting to HTML.

But, if you look into topic maps at all, you'll see that making them by hand is very labour-intensive. For my use case, automating the process is complete overkill. Sublime Text, being the GOAT, has a very intuitive "snippets" feature that lets me turn each entry in the topic map into a form. My snippets include some pre-written code and some variables that you can just type in like a form field. It is important that you get the syntax right before you copy it 100 times, so I'm also using Ontopia to check if my XTM is compliant. Ontopia kind of sucks--I have no idea why Java of all things was so popular back when it was written--but it validates the XTM and gives me a feel for whether my map is actually useful or not. At some point I'll come up with my own solution that generates a static HTML site from XTM, but that's a medium-term goal. If you're interested in XTM and HTML generation, legally acquire this book and check out chapters 6 and 9 especially.

One of the required fields in an XTM topic is a unique ID. For the most part I'm picking human-readable IDs because I'm making the map by hand, but associations are sort of "dead-ends" on the map (their IDs are never referenced) so I use randomly generated IDs for them. I made a plugin to generate them. Ctrl+Alt+Q inserts a unique ID at the cursor position.

Download!

In Sublime Text, click on Preferences > Browse Packages..., make a new folder called "uidgen" and extract the files there.