Reputation: 3449
In Eclipse, one can use ctrl + click
to go directly to a function definition.
For example:
f = my_tool.main()
If I ctrl + click
on main()
, then I will be directed to the code for the main function in the my_tool
module.
Is there a equivalent functionality in Sublime Text?
Upvotes: 0
Views: 2298
Reputation: 11
This can now be done in Sublime Text. If you hover over an identifier it will now pop up with a menu that can lead to the definition. This is rather slow to wait for the pop-up and you wanted the Ctrl+Click. To get it you need to add a custom mouse binding. How to make one and where to save it can be found in the Sublime Text Mouse Binding Docs.
For example on my Linux machine to get to the right directory use Preferences > Browse Packages...
and find the User
directory in this folder. In the User
directory add a Default (Linux).sublime-mousemap
file. Note: The Linux part will be different if you are not on linux. I think the identifiers are Windows
and OSX
.
Within the file you can add this:
[
{
"button": "button1",
"count": 1,
"modifiers": ["alt"],
"press_command": "drag_select",
"press_args": {"additive": true}
},
{
"button": "button1",
"modifiers": ["ctrl"],
"count": 1,
"press_command": "drag_select",
"command": "goto_definition"
}
]
The first entry is to reassign the previous functionality of creating multiple cursors to Alt+Click. The second assigns goto definition to Ctrl+Click.
Upvotes: 0
Reputation: 14498
Another method is to install CTags for SublimeText.
The default bindings allow you to either place your cursor in the function name and type ctrl + t, ctrl + t
, or use the mouse binding and do ctrl + shift + left-click
. This will take you to the function definition, either in the same file or a different file. You can then do ctrl + t, ctrl + b
or ctrl + shift + right-click
to jump back.
Upvotes: 0
Reputation: 14929
While Daniel's answer is the standard way for a ST user of achieving what you want, you can get a similar feature with the help of SublimeCodeIntel plugin. You can highlight a method or class > right click > goto definition. Or you can configure custom keyboard shortcut so that you can highlight and press the defined keyboard combination and you'll be taken to the method definition.
Upvotes: 1
Reputation: 10666
Something somewhat similar is to press ctrl+p
and type <filename>@<methodname>
. As usual Sublime uses fuzzy search so you don't have to be very exact when doing this.
Another nifty little trick is to do the same but instead type <filename>:<linenumber>
, which will take you directly to that line. This is handy when you get exceptions or errors.
Upvotes: 3