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

Xcode

Xcode Problem Overview


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)

Xcode Solutions


Solution 1 - Xcode

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).)

Solution 2 - Xcode

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

Solution 3 - Xcode

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").

Solution 4 - Xcode

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.

Solution 5 - Xcode

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!

Solution 6 - Xcode

"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.

Solution 7 - Xcode

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTheLearnerView Question on Stackoverflow
Solution 1 - XcodezoulView Answer on Stackoverflow
Solution 2 - XcodepurplecabbageView Answer on Stackoverflow
Solution 3 - XcodeGavin ThorntonView Answer on Stackoverflow
Solution 4 - XcodeD.McG.View Answer on Stackoverflow
Solution 5 - XcodeLuca DavanzoView Answer on Stackoverflow
Solution 6 - XcodeVincentView Answer on Stackoverflow
Solution 7 - XcodeNathan PerryView Answer on Stackoverflow