Tristan Hume

Github Resume + Project List Blog

Disassembling Sublime Text

This afternoon I spent some time with the free trial of the Hopper Disassembler looking through the binary of Sublime Text 3. I found some interesting things and some undocumented settings.

Undocumented Settings

The most potentially useful and interesting thing I found were some undocumented settings for Sublime Text. A couple of them could even be useful to some people:

There’s also the undocumented command line flags:

I discovered these settings by running strings on my Sublime Text.app/Contents/MacOS/Sublime Text binary and looking near the things I knew where config options for things that looked like config options, then trying them out.

Debug rendering mode Debug rendering mode

Libraries Used

The Sublime Text release binaries don’t have symbol names stripped out, probably for debugging reasons, and for that I’m very grateful because it’s really cool. The assembly is still largely indecipherable to me, but there are some cool things I can find out.

From the function names I can also see some of the libraries used in the making of Sublime Text. Here’s a partial list:

Internal names

I can also see some general architecture and what things are named. This is just cool trivia.

God how I wish any of these were open source. Each of these would be useful in many things other than text editors. There’s no app I know of that has its own custom-rendered UI framework that manages to be as fast and smoothly integrated with the OS as skyline and px are. The custom regex engine would be a handy library as well. I do understand that these goodies might not have existed in the first place if Jon couldn’t make money off of Sublime Text though, so I’m grateful that I at least have one beautiful and fast cross- platform app.

More

I also tried to figure out how some parts of the editor work and why they are so fast, but I couldn’t figure out much from the assembly. All the key functions have hundreds of basic blocks and are enormous with everything inlined. If I spent an entire day I might be able to reverse engineer one function, but that wouldn’t get me very far.

If there’s anything you’re interested in about Sublime Text’s internals, leave a comment and I might take a look. Especially if it’s a tiny behaviour improvement that isn’t accessible to the plugin API but might be possible to patch in the binary, with a debugger, or with something like Frida.

Edit: Updates

After this article was posted on Hacker News and cross-posted to the Sublime forum, @wbond, the Package Control maintainer and new Sublime developer replied with some corrections and new info. I’ve updated the library listing above with the new info.