40
votes

How do you switch between header (.h) and implementation files (.cpp) in Eclipse when using the C++/CDT environment with a keyboard shortcut?

In XCode you can quickly switch between headers and implementation with applekey option and up/down arrow keys. I was hoping that eclipse had something similar, but I haven't found it yet.

5

5 Answers

41
votes

Ctrl + Tab.

See in menu Window --> Preferences --> "General" category (far left) --> Keys --> "Toggle Source/Header"

7
votes

Ctrl + Tab is the default shortcut and here is a list of some of the more useful shortcut keys in Eclipse.

2
votes

Ctrl + Tab is the default shortcut. You can change it in Window->Preferences->General->Keys - Toggle Source/Header

1
votes

F3 to jump between declarations and definitions of specific methods

This is another good one to know in this context:

  • double click on the method name with the mouse, selecting it
  • hit F3 (shortcut for Right Click > Open Declaration)

This takes you from the declaration (.hpp) to definition (.cpp) and vice versa depending on which one you are currently in, which is useful if you want to go to the other file to see a specific method when the file is large.

Tested in Eclipse CDT 2019-09.

0
votes

You can also Ctrl + click on an identifier ( method name of member,... ). That way you seldomly need Ctrl + Tab.