void.pointer
void.pointer

Reputation: 26355

How do I toggle header/cpp file via keyboard shortcut in Visual Studio Code?

I'd like a simple keyboard shortcut to swap between the header (h, hpp) and CPP files. Visual Assist for Visual Studio allowed me to do this via ALT+O. Is there a similar keyboard binding for Visual Studio Code?

Upvotes: 41

Views: 49031

Answers (5)

thakis
thakis

Reputation: 5889

If you're using the clangd plugin already, then you don't need an additional plugin and can use cmd-opt-o.

Upvotes: 2

FluxLemur
FluxLemur

Reputation: 1993

You can use the extension ms-vscode.cpptools to Switch Header/Source.

  • If you're on Mac, then the shortcut is ⌥ O (option + O key).
  • On Windows, the shortcut is Alt+O.

Old answer:

There are currently a couple of extensions that support header/source file toggling:

You can find more by searching the words "switch toggle header source" in the extensions tab in vscode.

Upvotes: 68

iambackend
iambackend

Reputation: 83

In my case builtin IntelliSense solution conflicted with clangd plugin that I use, so the solution that worked for me was using aforementioned Header source switch plugin.

Upvotes: 0

Mason McCuskey
Mason McCuskey

Reputation: 29

No need for an extension, this is now built into Visual Studio.

The command you're looking for is:

EditorContextMenus.CodeWindow.ToggleHeaderCodeFile

It's by default bound to Ctrl-K, Ctrl-O.

Upvotes: 0

NamNguyen
NamNguyen

Reputation: 27

Ctrl + Tab, press it one and it'll always swap between A.cpp and A.h file.

Upvotes: -8

Related Questions