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:

Blog at