#include Auto Complete


One of the new features for C++ in Visual Studio 2010 is the auto completion of #include statements. Overall it’s a pretty simple feature and the behavior is exactly the same as regular IntelliSense auto completion. When you invoke it if there’s an exact match to complete your term the match gets completed, if there’s no exact match you get a list of available options (the equivalent of Member List for regular IntelliSense).


There are two modes of using the feature, which are for the most part the same two modes of #include statements (detailed information is available on this MSDN topic):


Double quotes – This gives you the list of available files on the current directory of the solution (or a specific path).

Angle brackets – This gives you the list of available files from the relevant include paths.


As you would expect from regular auto completion, you don’t get a full list of items every time but rather a filtered list based on your initial input. Also while you’re typing the index of the list keeps filtering based on your input. One of the added benefits of the feature is that you also get folder names in the list which when expanded acts as an extra filter and shows you just the contents of that folder.


#Include Auto Completion - Double Quotes 


 #Include Auto Completion - Angle Brackets


As you can see from the screenshot hovering over any of the entries brings up the tooltip which tells you the full location of the file you’re including.


Another benefit that you get as an added bonus is the ability to navigate your file system while using #include statements. Let’s say for example you want to include a file that you know it’s on a subfolder somewhere on your C:\Temp directory. By typing #include “C:\Temp” you’ll get a list of all the subfolders and files in that folder and you can then navigate from there. You can also use relative paths here (#include “..\..\MyHeaders”) or even navigate to the root folder of the drive from where the solution is located at (#include “\Temp”).


 One last thing worth mentioning here is where the include paths get pulled from. These come from directly from the project settings which you can access by right clicking on the project on the solution explorer and selecting the properties menu item (more information on this blog post).


Comments (1)

  1. Michael Price says:

    Is is possible to filter out certain patterns (say… "Debug" and "Release") from the list of possible values during the auto-complete process?

Skip to main content