Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

For the last eight years I wait for Microsoft to add the basic C++ functionality of switching back and forth between .h and .cpp files, and it keeps astonishing me it is still not supported in Visual Studio 2010. Does anyone know why they refuse to add this essential feature?

share|improve this question
4  
This question is asking for pure speculation, you would need to ask the authoritative body which made the decision to know. –  Jimmy Hoffa Aug 1 '13 at 20:07
add comment

closed as off-topic by Jimmy Hoffa, Dan Pichelman, Eric King, MichaelT, GlenH7 Aug 2 '13 at 3:57

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

Visual Assist does it, but also offers you to open any file in your solution which has a name that includes the substrings you give. Extremely useful in my opinion: I always use it, but very hardly use the 'jump to header/source' command...

share|improve this answer
    
You are right. I loved the feature and finally discovered Quick Open File, a free plugin that offers the same functionality. –  Dimitri C. Dec 14 '10 at 11:03
add comment

It's easy to write a macro that does it: Switch between Header and CPP File for Visual Studio .NET by Pavel Sokolov, Pierre Arnaud

Pavel Sokolov's Solution

A simple macro that allows you to quickly switch between the associated header and implementation files. This is a modification for Visual Studio .NET of the macro by Nooruddin Kapasi.

This macro simply switches between a *.h file and a *.cpp file, without any errors (if the *.h or the *.cpp file does not exist)...

Pierre Arnaud's Solution

The Switch_H_CPP macro switches between the active document (either source file or header file) and its counterpart (either header file or source file). Whereas simpler macros get this job done more efficiently (see the above), they do not work if the header files and source files are not stored in the same directory...

Switch_H_CPP looks for a matching counterpart by walking through all the loaded project files. It can, therefore, deduce the full path of the file and open it even if it is in a different directory as the active document...

share|improve this answer
    
Why do it yourself when others have. :) Nice find, +1 –  Default Dec 14 '10 at 10:17
1  
Of course, but my point is that it is an absolutely essential feature that would take 5 minutes to implement, but for some reason Microsoft doesn't choose to. I suspect political reasons, hence my question. –  Dimitri C. Dec 14 '10 at 10:21
    
@Dimitri: Why include something in the base installation when it takes 30 seconds of searching to find? People complain that Visual Studio is too bloated as it is... –  Dean Harding Dec 14 '10 at 10:22
add comment

I've not used Visual Studio for a few years, but IIRC the "Go To Definition" and "Go To Declaration" functions do this (albeit badly, particularly when it comes to constructors)

I imagine that one reason for them not implementing it on a filename basis is that there is nothing about C++ that enforces a convention on the arrangement of classes in files.

e.g. The "obvious" way to arrange a class called "MyClass" in a C++ project is to put the class in MyClass.h and the methods in MyClass.cpp.

Another, totally plausible way is to put the class definition in "elephant.h" and the methods in "mouse.cpp"

You could put all of your classes in one "classes.h" file and define all of your methods in one method per file.

I'm not saying that you should arrange your projects in this way, just that you could, and that's why jumping between .cpp and .h files is implausible, unless done in the same manner in which it is already implemented.

share|improve this answer
add comment

As discussions on Visual Assist shows, this feature is far from simple: which extensions are included (.c, .cpp, .cxx, .h, .hpp, .nothingatall, .inl, ...), which way you cycle through them when there are more than two, etc.

I agree it's still a rather simple feature to implement, but it's not as simple as you think.

share|improve this answer
    
disagree: back in VC6 days there was a tool called WndTabs that added tabs to the interface, and had a lot of useful features, including the .cpp/.h switch, they managed it very well. Wish MS had put all this into later versions of VS :( –  gbjbaanb Aug 18 '12 at 23:02
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.