• RSS Feed

Auto Using and Add Include Directives

When you type a symbol known to Visual Assist but not within the current file, Visual Assist can insert a directive in your current file to make the symbol known.

Using Directive in C#

Reference a common .NET type, and Visual Assist suggests adding the appropriate using directive. Accept the suggestion and Visual Assist inserts the directive near the top of the current file, without changing the position of the text caret.

Visual Assist suggests directive as you type

Unlike the similar feature in Visual Studio, Visual Assist presents the using suggestion as you type. There is no need to expand a smart tag.

IDE without Visual Assist

Include Directive in C/C++

Hover over an undeclared identifier and choose "Add include" from a refactoring menu (Shift+Alt+Q) to insert the appropriate directive. The directive is inserted after the last #include in your current file, outside of any #ifdef directives. The position of the text caret is unchanged.

Add #include found in refactoring menus

Visual Assist suggests #include directives for symbols found in the directory settings of your project/solution. If "Add include" is missing from, or disabled in, a refactoring menu, add the appropriate directory to your project settings.

Lack of "Add #include" is a hint to add directory to IDE settings

Caveat in C/C++

"Add include" makes the addition of headers convenient. Rely on compiler errors, and your knowledge of header hierarchy to know if a #include is required. Squiggles from the IDE are deceptive. 

Visual Assist adds the header that contains the definition of the symbol, not an umbrella header that includes it and other related headers. (There are a few exceptions, as Visual Assist is aware of several popular header hierarchies. In these cases, Visual Assist adds the umbrella header.)

Do not carelessly add headers, since Visual Assist lets you add the header that contains the definition of the symbol, even if you have already included an umbrella header.