Economics should be open

April 22, 2014

Sublime Text 2, adding stata syntax highlighting

Filed under: Uncategorized — howardchong @ 7:00 pm

I use non-Stata editors for do files because they look better an integrate better into my workflow. One editor I use is Sublime Text 2.

I use this because other programmers told me to use it. It’s great for HTML, Ruby, Python, etc. It’s not free, but there is a free evaluation version. It just bugs you in increasing frequency if you don’t register.

The killer feature for me is “Find in Files” CTRL+SHIFT+F. It lets me search all my do files for a command, gives me the results in a color coded file, and then I can double click to go to that file.

I also like that it is white text on black background. My eyes don’t like black text on white background. In fact, I think my preference is for yellow on black (old IBM) or cyan on black (old DOS days.)

Out of the box, Sublime Text 2 does not do syntax highlighting. So, you have to add it yourself.

The guide to do it is sorta here:

Except, that’s for textmate. Luckily, textmate uses the same syntax definitions. (I love programmers and reuse of code).
So here are the steps:

  1. download the file for textmate from and unzip
  2. navigate to Syntaxes\stata.tmLanguage
  3. Save this file in your user directory. For example, on Windows, my user directory is here: “C:\Users\howardchong\AppData\Roaming\Sublime Text 2\Packages\User”
  4. NOTE: If you can’t find your user directory, got to Sublime Text and do CTRL+` and then type: “sublime.packages_path()”. This will give you almost to the right path. Go to the “User” subdirectory and that’s the right path.

Text highlighting should now be enabled.

(NOTE: If this doesn’t work, you may also have to add package development. Follow the instructions here:

I would appreciate if you post a comment if you did this and it works.

An alternate stata.tmLanguage is here:



  1. There are several standalone packages for Stata already. Search on, and install with package control.

    Comment by Paul Yiming Li — April 22, 2014 @ 9:04 pm

    • Thanks! That is very helpful.

      Just a note: The packages on Package Control are noted as for OSX. Installing on Windows7 broke Sublime Text 2. It gives a startup menu error for me.

      Comment by howardchong — April 22, 2014 @ 10:26 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: