I have put together a Stata language module for TextWrangler. It has syntax coloring support for many Stata keywords (functions, options, etc) as well as block and inline comments. To install,

  1. Download the module here
  2. Copy the file to “username/Library/Application Support/TextWrangler/Language Modules”

Using BBEdit

This language module also works with BBEdit (as of version 8.5). However, to use the module, you must create the directory

~/Library/Application Support/BBEdit/Language Modules

since it is not created by default after installation. Then simply copy the Stata.plist file into that directory.

Notes
This module would not have been possible if not for the Crimson Editor syntax files, available here, by Cai Yong. Almost the entire keyword string list is based on his work.

I was unable to incorporate both “*” and “//” for line comments. Since I use the asterisk style more often, I encoded it as the line comment character instead of double slash. This can easily be changed. If you know (or figure out) how to use both styles simultaneously, please contact me via dataninja at gmail.

More generally, I’m sure that this could be done more elegantly. As always, this file is open source. Modify at will, but if you make the module a lot better, please set me know, so I can use your version…

Update
Thanks to RonĂ¡n Conroy for adding keywords for the SSC packages and for fixing the single-quote open string key.

Update
The language module has been updated to work with BBEdit version 8.5. Either download the updated module (above) or replace the following line in the Stata.plist file manually:

<key>BBLMLanguageCode</key>
<string></string>

with

<key>BBLMLanguageCode</key>
<string>STTA</string>

Leaving this line blank was a mistake on my part. Hat tip to Steven Samuels for first discovering, then fixing, the error.