Keyboard shortcut for Jump to Definition
Asked Answered
G

6

76

I'm looking for a keyboard only shortcut for Jump to Definition. The built-in shortcut requires the mouse: + Double click.

I've tried to add a regular keyboard shorcut for the Edit>Find>Jump to Defintion menu command, but, alas, it will only work when the method name is selected. I'd like to be able to position the cursor within the method name, class name, or other symbol, and hit something like +Shift+L.

Does anyone know of a solution, perhaps using a script, for the problem?

Update: The keyboard shortcut works sometimes and sometimes not. When I position the text cursor on a method call with no parameters and press +Shift+L it takes me to the definition. But it doesn't work for a method that takes an id parameter. However it works if the parameter is an int.

I have submitted a bug report to Apple.

Gareth answered 9/2, 2010 at 10:5 Comment(4)
I'm having a similar problem here. It seems to be related to whether the word for which you're looking up the definition is selected or not. Weird thing is, I've just transferred my system and it was working fine on the old one...Johathan
This is not a keyboard shortcut -- Do a ⌘ + clickSpectacles
Did you figure out how to pop back to the previous contextPlashy
You can pop back by swiping to the right on the track padObsequious
D
98

In Xcode 4.5.2 the shortcut now is ^ + + J (more readable Ctrl + Cmd + J).

Doublefaced answered 16/1, 2013 at 8:44 Comment(2)
Yeah that's the shortcut and it works. You can reconfigure it in Preferences/Key BindingsSquarerigged
Any idea if it's possible to jump to the implementation(s) when using protocols? It would open a selection popup or something if there are multiple implementations.Glabrescent
E
46

For Jump to Definition feature, you have the following 4 options:

  1. Ctrl + Command + J
  2. Ctrl + Command + Left Click (One finger tap)
  3. Command + Right Click (Two fingers tap)

XCode 9 only:

  1. Go to Xcode => Preferences => Navigation => Change Command-click on Code to Jumps to Definition and then use Command + Left Click (One finger tap)
Ericerica answered 3/10, 2017 at 9:22 Comment(1)
I always like to add [Option] to option 1 to open it in the assistant editor.Migratory
P
17

For XCode (tested in Swift) following keyboard shortcuts work. Found very useful:

To go to the Implementation (probably definition in Obj-C) :

Ctrl + Command + J

To pop back to Previous context :

Ctrl + Command +

To go to the Forward context :

Ctrl + Command +

Plashy answered 19/6, 2015 at 15:43 Comment(1)
FYI: < and > are not arrows ... I would use "left arrow" and "right arrow". took me a while to understand.Starfish
A
6

Change it in Xcode Preferences -> Navigation , NOT Key Bindings enter image description here

Actually answered 12/10, 2020 at 12:37 Comment(0)
M
2

Try the following: Cmd+Option+ (or Cmd+Shift+D and select from list) or see this link re assigning shortcuts (this last option is probably what you tried already - it may require selecting the method).

Maniple answered 9/2, 2010 at 10:16 Comment(2)
That will take me to the header file, or the declaration. I need to get to the code, the definition. And yes, I've tried the shortcut re-assigning.Gareth
Yes, I see that's your comment on the SU link, sorry. When I set up the keyboard shortcut Cmd + Shift + J for the menu item Jump to Definition, it seems to work (in Xcode 3.2.1), even when the cursor is in a method, but I don't have any selection. By the cursor I mean the flashing text insertion cursor, not the mouse pointer. Sorry, I'm being a bit slow, but perhaps you could give an example of where it doesn't work?Maniple
C
0

May Be it can work

enter image description here

or try this way

enter image description here

Cupcake answered 25/1, 2019 at 7:39 Comment(1)
What does this have to do with the original question?Phidias

© 2022 - 2024 — McMap. All rights reserved.