rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Suggestion: Auto-jump to Functions/Subs #5398

Open ironfelix717 opened 4 years ago

ironfelix717 commented 4 years ago

Hi,

Perhaps this has been addressed or is simply not possible with the VB Editor.

Is there any way you guys can include an Auto-jump feature to a Function or sub?

For example, when reading code, if there is a function call or sub call and the user would like to see the code in that fuction or sub, it is often tedious to go to the project explorer and find the module, then scroll down to the code, etc... What I think would be awesome is if you could doubleclick the function/sub name and it Rubberduck would automatically jump to the module and show you the code directly.

For example:

Private Sub DoSomething() dim flag as string flag = "someargument" Call MySpecialFunction(flag) End Sub

Double clicking anywhere on the term "MySpecialFunction(flag)" would jump to the module and code that has 'MySpecialFunction()' located in it.

I included the argument in the function just for demonstration.

Hope this is possible! Thanks!

retailcoder commented 4 years ago

I would actually like that to be Ctrl+Click, to match the behavior of Visual Studio and ScriptLab, to name a few.

"Go to definition" was not implemented in Rubberduck, mainly because the functionality is already present in the VBE (Shift+F2), but that wasn't taking mouse-based navigation into account... and then there's the technical aspect, too: the VBE's code panes aren't ours, and the IDE is hardly telling us anything about what's going on in there.

Working out the code-pane character position of the mouse cursor through Win32 API calls isn't something I'm particularly thrilled to implement.

However mouse-based navigation is absolutely something we'll have to look at when we do implement our own code panes.

ironfelix717 commented 4 years ago

retailcoder,

Thanks for a timely reply.

CTRL + Click is perhaps a better option. However, I didn't even know this jump (SHIFT + F2) was even possible until you mentioned it, which makes this post entirely worth posting! I'm glad you mentioned that. My life should be easier now...

A mouse based solution would definitely be more intuitive and really look forward to that feature if you guys do end up going down that path.

Thanks again, keep up the great work.

Regards,

EDIT: Somewhat off topic, to your knowledge is there any way I could simulate SHIFT + F2 to another key in Windows to jump faster?

daFreeMan commented 4 years ago

I'm confused by how you "could simulate SHIFT + F2 to another key in Windows to jump faster". Would hitting F2 be "faster" than Shift-F2? Is that what you're after? (Note, remapping Shift-F2 to just F2 would be bad, since F2 is already used to bring up the Object Browser.)

Once you get used to using Shift-F2 is becomes very quick and natural, and you'll wonder how you ever got along without it.

As a follow up note, if Shift-F2 takes you to a different code pane (another module) Ctrl-Tab will return you to the one you jumped from, and Ctrl-Shift-F2 will take you directly back to where you were, even if your jump was within the same code pane.

2020-02-24 07_28_45-View

testingoutgith1 commented 4 years ago

@ironfelix717 You can use the software with your mouse if you have a mouse with programmable buttons/profiles or a hotkey scripting language like AutoHotkey/Python (py keyboard and py mouse).

IvenBach commented 4 years ago

@ironfelix717 if you right click on an identifier (Sub procedures name, variable, etc...) you can choose Definition which will take you to where that identifier is defined. If that doesn’t fit you can also use the filter option in the Code Explorer.