TheLearner
TheLearner

Reputation: 19507

How do I switch between the header and implementation file in Xcode 4?

How do I switch between the header and implementation file in Xcode 4?

In XCode 3 it was cmd and right or left (I think)

Upvotes: 108

Views: 43011

Answers (7)

Luca Davanzo
Luca Davanzo

Reputation: 21528

Also in Xcode 6.1/7.1 shortucts are the same:

Jump to next counterpart:
Ctrl+Cmd+Up

Jum to previous counterpart:
Ctrl+Cmd+Down

Personally, coming from eclipse, I change this shortcut with:

Ctrl+Tab

this combination insn't already binded to anything else.

Xcode -> Preferences -> Key Bindings

search for "Jump to next counterpart" and put the new keys combination.

PRO

This is more efficient than default bindings see that you can use one hand instead of two!

Upvotes: 2

zoul
zoul

Reputation: 104095

Ctrl+Cmd+Up or Down, but the shortcut seems a bit finicky and sometimes stops working, not yet sure when and why.


Be sure to FIRST click ON the actual code window...

that's the critical tip to ensure it works. Click anywhere at all on the actual code. (If you're active in one of the other many panes of Xcode, the keystroke combo has no, or different, meaning(s).)

Upvotes: 202

Nathan Perry
Nathan Perry

Reputation: 300

The command to swap between m and h files is CTL-CMD-up/down. It sometimes get stuck. To unstick it simply save the file, i.e. CMD-S, and the hotkey should work again.

Upvotes: 0

D.McG.
D.McG.

Reputation: 435

The reason the menu option has been split between:

"Navigate->Jump to Next Counterpart" and "Navigate->Jump to Previous Counterpart"

is because you can have more than just one header file and one source file with the same file name. Besides having matching .xib files for view controllers, I have separate .vsh and .fsh files for vertex and fragment shaders in my OpenGL program. Along with my .h and .cpp files that's a list of 4 files that I can navigate up or down through with one key binding, instead of hitting the same key binding 3 times in a row to cycle back from file 2 to file 1.

Upvotes: 4

Vincent
Vincent

Reputation: 4409

"but the shortcut seems a bit finicky and sometimes stops working, not yet sure when and why."

Sometimes Xcode loses track of which .m and .h belong together. This is e.g. the case when you open one of the files directly from the Finder. When you open the file from the file list in Xcode, it normally works okay. Although when you have moved files between folders & groups in the file list of Xcode, it will also list the relation between the files.

Upvotes: 1

Gavin Thornton
Gavin Thornton

Reputation: 1897

Ctrl+Cmd+Up or Down

The shortcut sometimes stops working!!

The menu option has moved to "Navigate->Jump to Next Counterpart" and "Navigate->Jump to Previous Counterpart".

In preferences the key binding is now under "Jump to Next Counterpart" and "Jump to Previous Counterpart".

Why Apple insist on changing the menu positions AND names of these things is beyond me! I mean "Counterpart"!?

Worth nothing that Ctrl+Cmd+Left or Right move between previous and next files that were viewed (I mean "counterparts") too. These are also under the key bindings "Jump to Next Counterpart" & "Jump to Previous Counterpart").

Upvotes: 6

purplecabbage
purplecabbage

Reputation: 495

Also, you can 3 finger swipe up and down on the touchpad if you have one.

Upvotes: 10

Related Questions