Add Include

We recently released a feature for C/C++ that has long been requested: Add Include.  A lot of work had previously been put into our #include completion listboxes – but that work is moot because now you don’t need to type #includes directives by hand.

The Add Include command is available when you place the caret on a symbol which is declared in a header file that is not directly included in the active file.

If the header that the symbol is defined in is already directly included in the current file, the command is disabled.  Otherwise, it is enabled – even though the dependency may already be satisfied by another directive that itself #includes the header.  This is by design as many programming style guidelines mandate explicit inclusion of declarations (as opposed to happenstance or indirect inclusion).

For types and functions, Add Include straightforwardly adds an include directive for the header in which the type or function is declared.  For variables that are declared in the active file, Add Include acts on the type of the variable (no need to go to the declaration of the variable to add the include for its type).  For variables that are not declared in the active file, Add Include operates in the same way as it does for types and functions.

While the command is available in the usual VA Refactor menus, the easiest way to invoke it (at least for keyboardists) is to place the caret on a symbol and press alt+x, r, n.