Sabtu, 24 November 2012

Sublime Text 2: jump to definition

Since I moved from netbeans (which no longer officially support rails) to sublime text 2, the only thing that I missed is jump to definition function, often when I need to know how certain method from a gem works I'm forced to search it manually inside that gem folder while on netbeans I can just use alt+click to instantly navigate there..

After some googling I found SublimeCodeIntel which most of the time isn't working and make sublime heavier instead. But at long last I found about CTags and a Sublime Package for it.

First you need to build the tags file by using Rebuild Tags from command palette, after that using it is pretty much similar to netbeans, but instead of alt+click we use ctrl+shift+click plus ctrl+shift+rightclick for returning to previous position and it's works perfectly... for methods inside the project..

Sublime CTags readme show a script to generate tags for gems which is works perfectly, it will generate tags from all gems specified in Gemfile, but adding the script each time I work on a project is kinda troublesome so I created a simple gem to add several rake tasks for generating tags. The gem basically add 3 rake tasks, one for generating tags for project, one for gems, and the last one for both project and gems.