How to get Sublime Text 3 to show Rake tasks in Symbol List

First off, if you haven’t tried Sublime Text 3 I highly recommend giving it a shot.  The minimap is a neat feature and useful for navigating large structured documents (when you don’t know what you’re looking for exactly) and seeing patterns in file content.  Add to that multi-select and multi-edit capabilities, the ridiculous number of add-on packages available (including TextMate bundle support), and the speed, cross-platform support, customizability, etc. etc… </fanboy>

So you want to see rake tasks in ST3 when you hit cmd-r (or ctrl-r) [Goto Symbol…]?  First you’ll need the syntax definition file for a Rakefile.  Then you just need to add a corresponding preferences file alongside the syntax file that will tell ST3 to show additional items in the symbol list.

1. Add Rakefile syntax definition

Grab my gist of the Rakefile.tmLanguage file and put it in your User Packages directory.  The easiest way to get to this folder is to run ST3 and go to Preferences -> Browse Packages…

This will open your Packages folder.  Inside you should see a User subdir (if not just create it now).  Place the Rakefile.tmLanguage file from above in the User dir.

2. Add Rakefile preferences

Next download this Rakefile.tmPreferences gist and place it alongside the language file from above.  You should have both files in the Packages/User dir at this point.

To test if it’s working, open a Rakefile and check the syntax mode in the lower right.  It’s probably set to Ruby in which case you just need to click it and choose Rakefile from the list (restart ST3 if it’s not there).

Once you have a Rakefile open and the proper syntax set, try out the Goto Symbol… feature and you should see tasks from the Rakefile listed as task :task_name 😀

Rakefile tasks in Sublime Text 3 symbol list
Rakefile tasks in Sublime Text 3 symbol list


Now how about getting ST3 to automatically switch to the Rakefile syntax when opening files named ‘Rakefile’?

Leave a Reply

Your email address will not be published. Required fields are marked *