My new job has landed me in charge of ~15 Rails apps that run a completely unfamiliar business domain, so Sublime Text 3's new Goto Definition has been an absolute life saver. It means when you come across code like this:

@importer ||=

placing your cursor somewhere within "Scorecard::Performance::Importer" and pressing command-shift-down arrow (OSX) takes you straight to the class so you can see exactly what it does. (A superb tip in its own right!)

However, several of the codebases adhere to the convention of using Ruby's single-line namespaced class definitions. Like so:

class Scorecard::Performance::Importer


Unfortunately, Sublime can't "find" classes that are defined like this. It only works if the classes are defined using nested modules:

module Scorecard
  module Performance
    class Importer


This is mildly annoying, as pressing a single key combination is waaay faster than browsing through the search results for the term.

The reason Sublime is unable to find the definition in the first form, is that by default, it considers "Scorecard::Performance::Importer" to be three separate words.

The solution is rather simple:

  1. go to Sublime's default preferences ("Preferences" > "Settings - Default")
  2. find the "word_separators" line and copy it*
  3. go to your user preferences ("Preferences" > "Settings - User" or press command-,)
  4. paste it in at the top (so you don't need to worry about commas)
  5. now remove the colon (:) from the character list

It should look like this (colon removed):

  "word_separators": "./\\()\"'-,.;<>~!@#$%^&*|+=[]{}`~?",

  // other stuff here

Sublime will no longer consider the colon to be a word separator, so it treats "Scorecard::Performance::Importer" as one word. Goto Definition to the rescue again!

Caveat: option-right/left arrow and command-d will now jump and select the entire "Scorecard::Performance::Importer", but this will probably be what you want more often than not anyway.

*Did you know: you can just place your cursor on the line anywhere and if you don't select anything before you hit the copy shortcut ('command-c'), Sublime will copy the entire line for you! #tipception