How to switch between header and implementation in VS2010?

Is this a keyboard shortcut or a free add-on in Visual Studio 2010 that allows you to switch between the header (C / C ++. H file) and the implementation (C / C ++. Cpp file)?

+18
visual-studio visual-studio-2010 keyboard-shortcuts shortcuts
Nov 15 '10 at 11:03
source share
5 answers

Visual Studio does not have a built-in keyboard shortcut to switch back and forth. A macro is definitely the best choice if you want to automate this with a single keyboard shortcut. See the answers to the previous question for a list of suggested options.

The Visual Assist X add-in provides this feature with the Alt + O shortcut (however, Express add-ins are not supported by Express versions of Visual Studio).

If you are trying to avoid using a macro, there is an alternative way to achieve a similar result, although this is a two-click process:

To switch from the header to the implementation: Right-click the a.cpp file and select "Go to Header File" from the context menu.

To switch from an implementation to a header: Right-click the identifier declared in the header and select "Go to Definition" from the context menu.
+9
Nov 15 '10 at 11:39
source share

MS added this feature in Visual Studio 2013. This is the default keyboard shortcut Ctrl + K , Ctrl + O

To clarify: press Ctrl , enter K , enter O , release Ctrl .

You can find the command with which these cards can also be used with keyboard settings (tested on VS2015):

VS2015_Customize

+12
Dec 16 '13 at 23:21
source share

My workaround for this problem is a little unorthodox, but may help others, so I will share it.

I am using a list of windows . And I thought it would be annoying because of me it is, but I'm actually used to it. It continues to be used even in Visual Studio 2012, so I offer it as another alternative.

Once the .cpp and .h files are open, I switch between them like this ...

  • To switch from .cpp to .h: Alt+W, W, Down Arrow, Enter
  • To switch from .h to .cpp: Alt+W, W, Up Arrow, Enter

In fact, you hold down the Alt key while pressing W second time, effectively doing this: Alt+W, Alt+W, Down Arrow, Enter (you don't need to release the Alt key until you type the arrow key)

This works because .cpp and .h files are usually alphabetically adjacent in the window list. It also works for .c and .h for the same reason. Gap: Alt+W goes to the "Window" menu, and the second W activates the window list view "Windows ...". The active window will be selected in the list, so pressing the up or down arrow will move to the document that is before or after the alphabet, which is almost always the corresponding .h / .cpp file.

As another alternative, I should also mention that if you put the .cpp and .h files next to each other on the window tabs, you can use: Ctrl+Alt+Page Up and Ctrl+Alt+Page Down to switch between adjacent tabs tabbed list.

I understand that you need to "prepare" by opening both documents, and this will be less than ideal, but as a rule, I have all the documents open, and I often use the Alt+W, W shortcut.

+4
Jun 26 '13 at 3:42 on
source share

Such a shortcut key is added to CodeMaid. CodeMaid is an open source Visual Studio extension

Ctrl + M then

http://visualstudiogallery.msdn.microsoft.com/76293c4d-8c16-4f4a-aee6-21f83a571496/

+1
Jan 03 '14 at 7:41
source share

In VS2010, the keyboard shortcut "EditorContextMenu.CodeWindow.GoToHeaderFile" does the same as the right-click menu. Unfortunately, it does not work as a switch to switch back. (Although you can use ctrl to go back if you started in cpp).

0
May 19 '11 at 18:20
source share



All Articles