Sublime Forum

Goto header/source for C/C++

#1

A feature I use often in IDEs when writing C/C++ is goto header/source when in a .cpp or .h file. Basically it should take the current file name, swap the ending extension with .h or .cpp (and try all header/cpp extensions), and open that file if it exists.

This can likely be done with a plugin, but should probably be standard.

1 Like

#2

Since this feature is

a) specific to a language (or, at least to a specific subset of languages)
b) not that hard to implement

i think might be better to implement it in a plugin.

1 Like

#3

This already exists: Goto > Switch File > Switch Header/Implementation

1 Like

#4

Ah nice.

It would be nice if everything in the menu would appear in the command palette. That is how I was searching for it before and never found it.

1 Like

#5

I would go further in this request and ask for a side view with the counterpart. Xcode for Mac has this feature and it is very useful. Every time I select a .cpp, the header of that file automatically shows up on the side view.

Thanks for the great editor. I’ve been looking for a lightweight replacement for XCODE, but was unable to find, until, a month ago I googled for “what is the best code editor for Mac” and I found your editor. This app is a masterpiece. Thanks a lot.

1 Like

#6

Is there a plugin to do this? Is it possible to make one?

1 Like

#7

I would like switch to header to be improved.

When the header already is open it will not open another instance and will just jump to the already opened one. I feel this behaviour is desirable. The problem is that this behaviour breaks down when the source is open in another split pane view. In that case it will open another instance in your currently focused pane.

I think the better behaviour is that if the header/source is open in any pane, it should focus to that file/pane.

2 Likes

#8

Does not work if files located in different directories.
But this plugin (Switch File Deluxe) works fine.

1 Like

#9

Using the Open-header plug-in an editing the user setting like that:

“auto_extension”: [

    // include h

    {

        "extension": ".h",

        "prefix": "/usr/include/"

    }

        ]

And then with ALT+D Sublime will open the header file that is store in /usr/include/

1 Like