ChatGPT解决这个技术问题 Extra ChatGPT

Eclipse keyboard shortcut: goto function name

Suppose I know a function name, but I don't know which file it's declared in. What Eclipse keyboard shortcut can take me to the function I'm looking for?

What I'm looking for is similar to Eclipse's:

Ctrl + Shift + R

except it will search for method names instead.

Sidenote

With Visual Assist X, I can do this by using the "Find Symbol" feature, which is executed with:

Shift + Alt + S

Ctrl+H, set 'Declarations' radio button
give man a fish - you gave him a breakfast, teach him how to fish and you gave him a life. A way to find any key board short cut is to go into Window->Preferences that search for a keymap, when keymap opens search for your action in question. There you go, now you can set your own key binding for that command.

J
Jasper

This is an old question, but for the sake of people Googling this, Ctrl + O opens the code outline search, which is what you were looking for.


I was searching for this, and your answer was correct for my question but not for this one. Your solution will go to a function in the current window. The op was asking for a way to go to a function anywhere in the project. Thank you for answering my question however.
A
Allan Pereira

Yeah, this is an old question, but I have a better solution: what about F3? And CTRL + O is what Windows users are looking for.


Of course it works on Windows. And CTRL+O only search in current file, and you must type name of the object you are looking for, even if you have cursor near it.
Use a Quick Type Hierarchy on the method if its part of an interface, then you can navigate to the implementation of the method.
Control + click or command + click is even better. Maybe map 'go to definition' to another key than ctrl or cmd. So that you go to default implementation directly.
On MACOS F3 is screen controll task, so i cant use that key for go to method
C
Community

Not exactly a direct shortcut, but you need to go through the Java Search dialog:

(Ctrl+H):

(Sergei mentions in the comments that you might have to select "Declarations" in the "Limit To" section)

https://i.stack.imgur.com/JZSAb.png


@VonC: just out of curiosity...what kind of program do you use to create such a nice-looking screenshot?
this is most near answer but Limit to should be 'Declarations'
@Sergei ok, I have included your comment in the answer for more visibility.
J
Jasper

Not sure if this is exactly what you want, but if you Ctrl + H, that'll bring up the search dialog. The default option (for me, using the Java EE perspective) is a Java search. I can type in the method name, and then select the 'Method' radio button under the Search For block. Note that the default option (again, for me) for the 'Limit To' block was the 'References' radio button. I had to change that to 'All occurences' in order to see the method declaration, and not just callers.


I completely missed your answer (I was busy preparing my meme-compliant screenshot, see meta.stackexchange.com/questions/19478/the-many-memes-of-meta/…). But I agree with your description of the solution. +1
S
StackExchange What The Heck

Press CTRL + Left Mouse Button on the name your function. Eclipse will open the clicked file with this function automatically.


A
Allan Pereira

I use Momentics, so I'm not sure if this is in Eclipse or in Momentics plugin, but if it is Eclipse I think this is exactly what you need: CTRL + Shift + T.


That comes with Eclipse OOTB. It only searches for classes though.
Perhaps you're talking about Java only? Well, my code base is C. I use Ctrl + Shift + T to bring up the box (probably called "Type Search" or something like that). I use to look function names across files in the project.
Yes, the context is a Java project in Eclipse with the Java EE support (although I don't see any reason why this feature wouldn't be in the plain Eclipse). I don't have a C project at hand to try this but, yes, I would image that the feature looks for something else in C perspective since there are no classes in C ;) Note: egrep -R -n "functionName" . in project root is a handy way to search for function usage/def... sometimes
It works for CDT, but for Java it searches classes only. Any similar for Java?
C
Cedric Reichenbach

Quick and dirty is to use Ctrl+Shift+Up/Down, which jumps between members (methods, variables) in Java.


What's the equivalent for OS X ?
I don't know, but on OS X, the Ctrl is usually replaced by ⌘ (Command) for shortcuts, so I suggest you try ⌘ (Command)+Shift+Up/Down.
T
Tshilidzi Mudau

If the method in question is on an interface, then using Quick Outline or F3 to jump to the definition will only take you to the interface definition. This isn't often what I want. Instead I hit, on my mac, Cmd + T on the method to get a Quick Type Hierarchy. From the type hierarchy you can go to the implementation of the method.


S
SaiPawan

Simply hitting F3 by placing cursor on the function name will work for windows users.


N
Nachan C

simple 2 ways to function declarations:

Way 1: ( Whole workspace ) Ctrl + Left Click the function calling place.

way 2: ( within the same page ) press Ctrl + F to find dialog window and type n function_name and search.

these will redirect to function definition