67

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

Patrick Brinich-Langlois
  • 1,381
  • 1
  • 15
  • 29
sivabudh
  • 31,807
  • 63
  • 162
  • 228
  • Ctrl+H, set 'Declarations' radio button – Sergei Krivonos Jan 05 '14 at 15:07
  • 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. – A_P Dec 04 '18 at 15:29

10 Answers10

79

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.

Jasper
  • 2,166
  • 4
  • 30
  • 50
user35147863
  • 2,525
  • 2
  • 23
  • 25
  • 16
    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. – Dearmash Jun 30 '11 at 22:53
78

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.

Allan Pereira
  • 2,572
  • 4
  • 21
  • 28
SuitUp
  • 3,112
  • 5
  • 28
  • 41
  • 3
    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. – SuitUp Jun 27 '12 at 15:49
  • Use a Quick Type Hierarchy on the method if its part of an interface, then you can navigate to the implementation of the method. – David Mann Sep 21 '12 at 19:44
  • 3
    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. – MrSnowflake May 07 '13 at 10:33
  • 1
    On MACOS F3 is screen controll task, so i cant use that key for go to method – Makio Feb 21 '14 at 02:06
  • CTRL+O was what I was looking for, search a function by name in current file – gluttony Aug 30 '23 at 08:34
15

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)

Eclipse Java source search

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
8

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.

Jasper
  • 2,166
  • 4
  • 30
  • 50
elduff
  • 1,178
  • 3
  • 14
  • 22
  • 1
    I completely missed your answer (I was busy preparing my meme-compliant screenshot, see http://meta.stackexchange.com/questions/19478/the-many-memes-of-meta/19775#19775). But I agree with your description of the solution. +1 – VonC Apr 21 '10 at 18:40
7

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

romanbeldacz
  • 71
  • 1
  • 1
4

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.

Allan Pereira
  • 2,572
  • 4
  • 21
  • 28
user657862
  • 406
  • 5
  • 12
  • That comes with Eclipse OOTB. It only searches for classes though. – justin Jul 04 '13 at 18:23
  • 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. – user657862 Oct 13 '13 at 04:47
  • 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 – justin Oct 14 '13 at 13:19
  • 1
    It works for CDT, but for Java it searches classes only. Any similar for Java? – Sergei Krivonos Jan 05 '14 at 15:01
2

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.

Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
David Mann
  • 1,874
  • 2
  • 16
  • 19
2

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

Cedric Reichenbach
  • 8,970
  • 6
  • 54
  • 89
0

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

SaiPawan
  • 1,189
  • 7
  • 20
0

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

Nachan C
  • 79
  • 8