51

I'm using Sublime 2 for Ruby On Rails programming. I need a ability to click a method name and jump to class where the method is defined. There are many IDE with similar capability...

pjumble
  • 16,880
  • 6
  • 43
  • 51
Lesha Pipiev
  • 3,251
  • 4
  • 31
  • 65

3 Answers3

51

Goto symbol is Ctrl-R (linux), this gives a pop-up-list of all symbol and class definitions in the file, in definition order, and you can jump to what you're after. You could do the same thing with Goto Anything, Ctrl-P and then typing @ and the method name.

Also, there is a Goto Symbol plugin, which lets you jump straight to the definition of the method name your cursor is at, with a key binding or click.

However, both those methods are limited to the current file. If you need to jump to definitions in other files, probably the best solution is the SublimeCodeIntel plugin. It seems to be working pretty well and just by hitting Ctrl-f3 (linux) will open up the file at the definition you want.

Heinrich Cloete
  • 702
  • 5
  • 12
fraxel
  • 34,470
  • 11
  • 98
  • 102
  • 1
    superb advie thanks re sublimecodeintel - the lack of a find-in-project command is a remarkable omission from Sublime I was about to ditch it and go back to BBedit until I found your post – jpw Aug 13 '12 at 00:14
  • 3
    this is a good answer but unfortunately SublimeCodeIntel seems quite buggy, so my advice is to not waste time with it and try CTags instead as suggested by @alienhard – pic Aug 31 '12 at 07:58
27

Another solution is CTags.

SublimeCodeIntel seems to be pretty buggy judging from unresolved issues on the Github tracker. Also it crashes for me, probably because the code base I'm working on is too big...

What I'm using now is the CTags package. There's no "intelligence" but it allows you to jump to definitions and back very easily and it is super fast.

Bibhas Debnath
  • 14,559
  • 17
  • 68
  • 96
alienhard
  • 14,376
  • 9
  • 37
  • 28
  • How to do this process.I tried ctrl+click in the function call.but it is not jumping to function definition – shajin Mar 27 '13 at 06:02
  • 1
    I'm using these custom mappings: { "command": "navigate_to_definition", "keys": ["ctrl+option+]"] }, { "command": "jump_back", "keys": ["ctrl+alt+["] }, but obviously you can define your own. – alienhard Apr 12 '13 at 05:17
  • 2
    The problem is that it can only go to function definitions, but can't find variable definitions. – duleshi Sep 03 '13 at 03:43
  • For spanish layout: `{ "keys": ["ctrl+alt+x"], "command": "navigate_to_definition"}, { "keys": ["ctrl+alt+z"], "command": "jump_back"}` – Igor Parra Sep 30 '13 at 16:13
  • been 3 years, I wonder if they have any new package available to solve the issue of finding variable definitions – SandBag_1996 Feb 02 '16 at 17:16
5

upgrade to sublime text 3 and then put cursor on function name and click F12 to go back ALT+- or from the menu click on Goto

Eran Or
  • 1,252
  • 15
  • 22