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?

  • 4
    This question is asking for pure speculation, you would need to ask the authoritative body which made the decision to know. Aug 1, 2013 at 20:07

4 Answers 4


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

  • 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, 2010 at 11:03

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

  • Why do it yourself when others have. :) Nice find, +1
    – default
    Dec 14, 2010 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, 2010 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... Dec 14, 2010 at 10:22

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.


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.

  • 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, 2012 at 23:02

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