Cuco burés 4 years ago • updated by Pascal Seitz 1 year ago 58
It would be great to have a Go to definition/declaration option. Something similar to the one in NetBeans. Ctrl click a function/variable/class/...  name in the editor would take you to the definition/declaration of it. Even if it's in another file of the project.
Right, I was just going to post this idea.

Currently, you can highlight function name, wherever in source code, and press ctrl+shift+f for searching across project files. And then you get file names and contexts where the function name appears. 

But this can be simplified, something like if the current search function is looking for something like: funciton_name = function or funciton function_name etc.. (for few cases how function desclaration can show up in php/js (for what I'm interested in) code.
This is the one feature keeping me from switching full-time to SublimeText and keeping me with the memory-hog NetBeans
Ditto with PhpStorm.
This is killer-feature for me too. User should alsobe able to add source directories outside project to be searchable for definitions,

It is super useful when you using some framework and want to be able to fast jump to sources. Hope this will also be implemented.
Yes, it should be really cool to have this feature. It saves lots of time.
Same for me, I stick to Eclipse for feature like this and show inheritance (F4).
But I have the impression that there's no lightweight IDE really aware of your OOP. So welcome Eclipse/Netbeans.
You might want to try the SublimeCodeIntel package, if you're using one of the languages it supports (PHP, Python, RHTML, JavaScript, Smarty, Mason, Node.js, XBL, Tcl, HTML, HTML5, TemplateToolkit, XUL, Django, Perl, Ruby, Python3). I tried it on some of my JavaScript and it failed to find the definition for a function, even if it was declared in the same file, but your milage may vary.

My situation is similar, it doesn't work properly for me.

Same.. based on my experience as well as user comments.. SublimeCodeIntel is probably the most popular poorly written package. Very inconsistent.

Know where the definition is also allows you to extend the functionality with code hint! As if you can read the definition you can look it up when typed and offer code hint / template with the parameters the function / class accepts.

This is tricky as you will need to build this to be language aware 
This is the missing piece of the jigsaw for me too.  Although it has not stopped me moving from intellij
This is the only missing feature which has kept me from moving to SublimeText full-time.
Imo this is not something the program should be capable of by default.
There is an API which makes this kind of functionality possible, it just needs someone to write a plugin for it.

I never really used SublimeCodeIntel for this purpose but it worked when I tested it in Python.

SublimeCodeIntel actually works, but only inside one file. Try Alt+Click!


This has made my day! I tried installing the "Find function definition" package which looks within projects, but didn't seem to work within a single file. Before now, I've been adding bookmarks at function definitions (CTRL+F2). I never realised you can simply press Alt and click the function name! This is amazingly useful! thank you :D


Yea, this needs to be a feature that's inherit to the editor. It's huge and none of the plugins really seem to work that well. They do, but you have to keep remembering to rebuild the definitions. It's not automatic. Really frustrating. I am using Sublime without this feature for now and it really makes me want to switch back to NetBeans. I'm actually sorry I paid for Sublime at this point. The fact that I paid for it is why I continue to use it...To justify the purchase...But Sublime has such ENORMOUS potential to be a VERY fast and productive tool...Without this feature though, it's not as productive as something NetBeans. As mentioned below NetBeans (Eclipse, et al) run in JVM so it's memory intensive. I'd prefer not to run such a memory intensive IDE but again without this feature, I won't have much of a choice. =( Please prioritize this feature. I'll pay even more money to get it done.


I'm with Thomas Maiaroto on this one. I'd even pay for this feature on top of paying for Sublime Text as long as it worked properly.

It could be that the Sublime Text 2 dev(s) make their own plugin for it. Their search stuff seems very snappy so it could be that it could work off of that? I don't know. It'd be real nice to see this feature though.

I think that without any kind of intelligent parsing sublime could not really tell which is the correct definition for a sumbol (just think of two functions with the same name, in different namespaces...), it could offer a few valid options with a simple search...

a nice workaround would be to have a plugin or something that would just complete a "find in files" completing the sentence to look for depending on the selected language...

for example, if you are in a .scala file, it would look for "def <symbol>", and if you are in javascript it woulf look for "function <symbol> | <symbol> = function | <symbol>: function"

with this simple example it shows that this thing could get a bit complicated without proper language parsing...

but I agree, it would be a killing feature

Namespaces. Even PHP has 'em these days. Otherwise, yes, something like you're suggesting. It wouldn't have a lot of choice at that point and I've seen other editors come up with incorrect results, but paging through "possible" results would be good. Right now I just use a search throughout the project, but it's not a lot of fun.


It seems someone finally implemented that idea, and it seems to work really fine:

I've just submitted a few issues, the most annoying is this: https://github.com/timdouglas/sublime-find-function-definition/issues/3
can anybody give us a hand changing the cursor position after looking for a function definition, I guess it shouldn't be so hard


I think that's a very nice idea from opensas, infact, this could be something that's pretty cool and simple to make too.

It could easily build on ST2's built in search and find functions by doing a search for a specific string (i.e. "class className") and then if it finds just one match, open that file and goto the line it's on, if there are multiple results simply open a drop down with the path of the file on there too. The chances are that'll at the very least be a helpful, fast alternative to real go to definition.

It could be taken either way though it would mean that you could write any class, function, method, property or whatever in any file in your project and it could find it. Personally I think that'd be a good thing, I'm sure others would prefer it not to though.

that's exactly what I had in mind...

the tricky part would be to display the results of the search in a popup combo, I think

more over, it could be further customized for each language

unfortunately, I haven't developed any plugin for ST2, and I'm not very profficient in python either...


I've actually taken quite a liking to the idea of learning Python and developing this myself. I did find something similar that could work as a starting point though. If I do I'll post back here with it :)


good to hear it :-)

I hope I can give you a hand...


Need this. I was just falling in love with projects in sublime when I realized it didn't do this... deal breaker unfortunately.  I use that all the time in other IDEs

In need of this feature myself, I've seen some mention of CTags integration, which was my first thought going back to my vim days. Netbeans wins out in the end through it's implicit inclusion of PHP namespace/class path project settings features. Now netbeans is just very old fashioned and heavy weight, but it does that job not even perfectly, but even doing so in some way is enough to make it immensely useful.. 

It seems like the project file could include classpath or vendor library lists. Sublime has language context, otherwise language relevant snippets and syntax highlighting wouldn't work, so in the end this should be possible.  

I can imagine the argument against this, the speed impact of maintaining a class name and signature index would be in such contrast to the super speed Sublime has everywhere else, (Except for the PHPUnit plugin on right clicking on the content of an xml file that's not even a unittest.xml)

But the options should be explored for this feature type.


I think that's also a good place for it. The CTags solution doesn't work because it's not automatic. I'm not rebuilding them every time I add new classes, libraries, etc. Sorry but that's ghetto. It also works against the "speed" of SublimeText by slowing down your productivity. You're right NetBeans is a little more old school, it's resource hungry with the JVM, but not as bad as Eclipse.

However, I just wanted to add my two cents here...I don't think there's anything wrong with a little extra time (and it'll depend on the size of your project) when loading up a project. Maybe people switch between projects a lot more frequently than myself, but a few seconds to load up the project I don't think is a deal breaker over the significant value add that "go to definition" has.

If some people (me too) wanna pay for this then maybe someone capable should make kickstarter project for this?


SublimeCodeIntel has been working great for me. It was working on Windows just fine before, but I got it working flawlessly on Linux too and I've not had any problems since. Works a treat :), give it a try and let me know if you have any problems.

I know about CodeIntel but there is no Java support which I need :(


That's too bad :/, it's probably tough to do Java intel in something like Sublime, there's a lot to do compared to a lot of other languages I'd imagine. Not sure...

Yes, indeed. Hence my post :)

/edit: Maybe SublimeCodeIntel guys would take money for this? I think a lot of people would throw money at them for Java support ;)

I was not able to get SublimeCodeIntel to work for me, I'm going to try it again since everyone else is having success with it.

If you're on Linux, you need to build it, there is a src folder, just run the build script, if it fails, make sure you check the dependencies it's telling you to get, and just get them. Rinse and repeat until you've got it installed properly. 

Possibly the same on a mac. I wouldn't know though?


got it working, I had an older version I think.  Works great actually.

Unfortunately it is not working as i would expect it.
Simple ctrl+click (control+click on mac) will take you to definition inside the opened file only. 
If i try to ctrl_click on something like $class = new Class(); its not gonna work and nothing happens. Even tho if i choose from right context menu to go to definition, nothing happens.
So, it is not working great in PHP environment. Its barely working.

I'm currently using the ST3 BETA and it seems to already have this feature. I don't know if ST2 has it or not as I came late to the party.

Press F12 over a symbol and you will be given a list of possible definitions within your project that you can switch between.

Actually, it still doesn't work. It'll give you a bunch of choices and run a search for the method...But it won't actually find it if you're using namespaces. You'll need to know the path to find the file to jump to the function. At least for PHP...If you're using PSR-0 you should at least know which file to jump down to and open (Sublime will then jump to the proper place in the file)...But it's still not a complete go to definition solution.

Have you tried Follow Function PHP: https://github.com/draffter/FollowFunctionPHP

It works for opening PHP core functions but for my custom functions I can't make sense of the explanation on "Now, you can use plugin, by clicking two times button2 holding Ctrl+Shift on function name."

What is button2??

Button 2, is Second mouse button, aka, Right click. Poor english is my favourite.

Thanks mate!! On that note that plugin does work. I just tested it using aka Right click :) It does jump to the function declaration

It even gives you a list of all the overloaded functions within your project to choose from

No worries. Great stuff, glad it works! Let me know if you find one that works well with JS.

Me too, PHPStorm has this. Very handy to jump to a function to see what parameters are and read the comments above it. Very quick hot key then close tab to return.


1. Create file Packages/User/Default (Linux).sublime-mousemap

2. Add into it next lines:



"button": "button1", "count": 1, "modifiers": ["ctrl"],"press_command": "goto_definition"



  1. Go to Package Controll
  2. Install "Find Function Definition"
  3. Go to Browse Packages
  4. Go to "Find Function Definition" folder
  5. edit "go2function.sublime-settings" file
  6. add "class $NAME$", in the list of definitions
  7. go to some definition, double-click and press F8

I'm sure you've found this out by now, but for anyone googling this and finding it as the top result like I did - in Sublime 3 you can just select the function and press F12 to goto definition.

Did not know that Michael!  Thanks for the heads up.

Anyone knows how to bind ctrl + click to the new F12 find feature of Sublime Text 3?


Sublime 3 does not have this feature.

F12/"Go to definition" is a great draft of what's needed, except it is only a text-level feature and you'll often end up with a list of a dozen hits in various files that you have to wade through to find the actual definition, thus annihilating almost completely the usefulness of this mechanism. 

There needs to be at least a heuristic patch based on a smarter distance metric (e.g. folder distance from current file) that nearly always gets you the definition (and declaration if different) in the first 2-3 results.

But seriously, there needs to be real language-level understanding of entities, which would incidentally make autocomplete all the more useful.

Think about what a programming text editor is used: beyond from typing code at the current editing location, the thing you do most often when programming is mentally resolve how the local piece of code is linked to the next bigger scopes of your code base, most commonly through named references. Programming is about jumping up and down levels of abstractions, generally separated by functions that act as abstraction layer separators. 

Guess what, the one feature that helps most with that is: go to definition! as it allows you to just look what a symbol does exactly instead of having to keep that in mind. Code you call in the local scope is code that is part of what you write, even if you didn't write it ; you absolutely need to quickly reach all that source that is part of what you're writing, and that may ramify into 10 000 lines of code for a single function call. And surprise, the next or co-best thing that helps with that is autocomplete, which would also be solved by the same language level understanding.

For C++ there is currently no decent solution and even among the realm of plugins, none work and are maintained.

There is no way I can convert friends and co-workers to using an otherwise amazing piece of software without one of the most frequently used and essential features of a text editor for programming. 

Everything and more is perfect in Sublime except a few of the most essential, foundational features for programmers: Go to definition, autocomplete, contextualization of errors in the gutter. I don't care if it's a plugin, a core feature, if it works 100% of the time or heuristically 98%, but it needs to be done for Sublime to undisputedly be the best lightweight, fast programming IDE.

Agreed. Nothing that works really well for C++ so far. 

The closest I've come is to install both the CTags and CScope plugins, use the command line to get them to generate their databases and then bind F12 to CTags' Lookup definition. When it doesn't work, I fall back to CScope. Still, the results are mixed and therefore I still cannot rely on this mechanism.

From Sublime Text's point of view this could be made language independent by providing a key binding to jump between the definition and declaration of the function as a concept.

How a function definition/declaration is identified would be langage specific (and some languages don't have function declarations), but I don't see why for example, the existing syntax highlighting rules can't be extended to include the concept of a function (if they don't already have them).

If done that way, then all you would need is the syntax highlighting support for a language for this feature to work.

Comman + option + down arrow when cursor is within the variable/method name (for Mac at least)
+1 but sadly it's been so long since this suggestion was raised (2 yrs ago). Will this feature ever see the light of day in Sublime Text 3? Really praying for this! :)

I'm using RubyMine solely because of this feature. I'm stuck in using RubyMine because it allows me to peek into the source code of the gems I use so I can better understand the context of my projects. We spend more time reading and understanding code than writing it. This feature in RubyMine is more valuable to me than the productivity boosts that Sublime Text gives.

But Sublime Text is really better in everything else. I guess we can't have the best of both worlds (yet). So I hope this comment finds the package developers for Ruby well.. Please implement this! :D
@Devin: Works for Javascript, not for C/C++. In addition, there needs to be a way to extend this support for lesser known languages - like Rust, for example.
Jump to Definition is possible for C++ with the Sublime CTags Plugin