Sublime Text 2 CoffeeScript Setup

Sublime Text 2 and CoffeeScriptI’m using Sublime Text 2 for development on my Linux machine which has good support for CoffeeScript. If you are using Sublime Text 2 I recommend installing Package Control package manager by Will Bond and reading Using Sublime Text 2 for Development by Andy Miller. Sublime Text 2 supports TextMate bundles, to get CoffeeScript syntax highlighting just install the bundle through Package Control.

Install CoffeeScript Interpretor using your Linux distribution package manager or npm. I’m running Linux Mint 10, running my packager installer installed CoffeeScript to usr/bin. Make sure “path” is pointing to where the “coffee” executable is in your system (installing CoffeeScript using npm by running “npm install -g coffee-script” installs it to /usr/local/bin). There is no need to create a new build system file for CoffeeScript as one was created after installing the Sublime Text 2 CoffeeScript plugin. However, the path to CoffeeScript Interpretor needs to be verified before building.

After install Package Control, restart Sublime, access package control through the Command Palette using Ctrl+Shift+P. As you start typing commands, you get an overview of the available options. If you execute “discover packages” a browser pops up giving you a nice overview of all available packages and a search bar. To install a package, use command “install package”. Press enter to get a list of all available packages, type CoffeeScript, install it.

Verify Sublime CoffeeScript build file

  1. Open Sublime Text 2 Editor
  2. Preferences –> Browse Packages
  3. Navigate to CoffeeScript –> Commands
  4. Open CoffeeScript.sublime-build in Sublime
  5. Set “path” to the path CoffeeScript Interpretor was installed. In my case, usr/bin but your might differ.
  6. Save and Close

Set Build to Automatic

  1. Open Sublime Text 2 Editor
  2. Tools –> Build System –> Automatic

Create and build a simple CoffeeScript

  1. Open Sublime Text 2 Editor
  2. Create a new file by pressing Ctrl+N
  3. Paste the following code
My First CoffeeScript
 demoTask = (start, end) -> end - start
  1. Save As
  2. Build by pressing Ctrl+B or F7.
  3. A new file will be created called demo.js in the same directory as
My First CoffeeScript Generated to JavaScript demo.js
  var demoTask;
  demoTask = function(start, end) {
    return end - start;

For more information installing on Windows checkout Building CoffeeScript with Sublime on Windows by Kevin Pelgrims.