Controlling IntelliSense Through Macros

Visual CPP Team

Hi, my name is Jim Springfield, and I’m an architect on the Visual C++ team.  When I recently blogged ( about improvements to Intellisense and overall UI responsiveness, I mentioned that there was a new mechanism that allows a developer to control some of the Intellisense options.  This will work on the released version of Visual Studio 2008 or on Visual Studio 2005 if you have installed the publicly available QFE (also called a General Distribution Release, or “GDR”) for VS2005.

Here are a couple of late-breaking notes about the GDR.  This GDR requires VS2005 SP1, so make sure and install that first.  Also, there are apparently problems with installing the GDR on non-English versions of VS.  Hopefully, this is resolved soon.

In general, these advanced settings should be unnecessary except for extremely large solutions or other special situations, especially given the improvements we recently implemented.  While there is no UI provided for accessing these settings, I will describe how you can create macros and assign those macros to toolbar buttons in order to more easily access these settings. 

First, bring up the Macro Explorer, which can be accessed through “Tools|Macros|Macro Explorer”.  In the Macro Explorer window, right click on the “Macros” node and select “New Macro Project”.  Select “Macro Project”, give it the name “Intellisense”, and specify a location to save it.  A macro project will be created along with a module called “Module1”.  Change the name of the module to “IntellisenseModule” by right clicking on the module and selecting “Rename”.  Next, right click on the module and select “Edit”.  This will bring up a new Visual Studio window with an empty module in it.  Paste the code from Figure 1 into this window and then select “File|Close and Return”.  You should see the five subroutines listed underneath the module now.

OK, you now have the code in place and you just need to assign these macros to toolbar buttons.  Select the “Tools|Customize…” menu item and click the “New…” button on the toolbars tab of the dialog that came up.  Give it the name “Intellisense” and click OK.  There should be an empty toolbar just to the right of the dialog box.  Select the “Commands” tab in the dialog, and scroll down the categories list box and select “Macros” from the list.  You should see the macros from the code you previously pasted.  The first one should be named “Intellisense.IntellisenseModule.DeleteNcbAndReload”.  Click and drag each of the five macros to the toolbar that you just created.  As you drop each one, a button will be created with just the name of the macro displayed on the button.  After dropping the button onto the toolbar, you can right click on each button and change the text and pick an icon for the button.

To give you a preview, here is what it looks like when everything is done.  In your version, the text doesn’t need to be this long or you could create custom icons for it.  You could also add these commands to menus.

Intellisense On

This is the normal mode of operation and all aspects of Intellisense will be operating as normal.

Intellisense Off

In this mode, most of Intellisense is disabled, although if an NCB file exists, it will be opened, however no background parsing or updating or any queries will be directed to it.  This isn’t quite the same as deleting “feacp.dll”, which some customers have resorted to, although it is very close to the same.

Intellisense NoUpdate

This setting disables any reparsing of files when they become dirty and therefore no significant updates to the NCB are made.  This mode is useful when editing core header file s that would trigger a reparse of significant portions of the solution.  When you turn Intellisense back on after being in this mode, the IDE will do a rescan of the solution and mark any changed files for reparsing.  This scan isn’t very expensive and is identical to what happens when you open a solution, but if a significant number of files need reparsing, that work will still happen in the background.

Intellisense Status

This macro queries for status and displays a message box showing what the current Intellisense settings are.


This macro doesn’t actually rely on any new functionality.  It simply closes the solution, deletes the corresponding NCB, and reloads the solution.  This is useful if Intellisense starts acting flaky such as not returning any correct information.  When the solution is reloaded, it will reparse the solution and regenerate the NCB file.

Important notes:

1)      These settings are persisted when the IDE is shutdown and are not tied to a solution or project, so don’t turn off Intellisense for one solution and then wonder why it isn’t working for another solution.  It is probably possible to create a macro that will remind you of this when loading a solution, but I haven’t looked into that.

2)      Even though the settings are not per solution, changes to the settings may be ignored if there is no VC solution loaded, so make sure you have a VC solution open before changing the settings.
(The actual issue is whether vcpkg.dll is loaded in the VS process.  If it isn’t these macros won’t change the real settings.)

Figure 1

Imports System

Imports EnvDTE

Imports EnvDTE80

Imports System.Diagnostics



    ISENSE_NORMAL = 0       ‘normal (Intellisense On)

    ISENSE_NOBG = &H1       ‘no bg parsing (Intellisense Updating Off – although NCB file will be opened r/w and repersisted at shutdown)

    ISENSE_NOQUERY = &H2    ‘no queries (don’t run any ISense queries)

    ISENSE_NCBRO = &H4      ‘no saving of NCB (must be set before opening NCB, doesn’t affect updating or queries, just persisting of NCB)

    ISENSE_OFF = &H7        ‘no bg parsing, no queries, no saving of NCB, ncb will still be opened, however

End Enum


Public Module IntellisenseModule

    Sub Intellisense_NoUpdate()

        DTE.Properties(“TextEditor”, “C/C++ Specific”).Item(“IntellisenseOptions”).Value = ISENSE_FLAGS.ISENSE_NOBG Or ISENSE_FLAGS.ISENSE_NCBRO

    End Sub

    Sub Intellisense_Off()

        DTE.Properties(“TextEditor”, “C/C++ Specific”).Item(“IntellisenseOptions”).Value = ISENSE_FLAGS.ISENSE_OFF

    End Sub

    Sub Intellisense_On()

        DTE.Properties(“TextEditor”, “C/C++ Specific”).Item(“IntellisenseOptions”).Value = ISENSE_FLAGS.ISENSE_NORMAL

    End Sub

    Sub Intellisense_Status()

        Dim x

        x = DTE.Properties(“TextEditor”, “C/C++ Specific”).Item(“IntellisenseOptions”).Value

        Dim result


            result = “Intellisense On”

        ElseIf x = ISENSE_FLAGS.ISENSE_OFF Then

            result = “Intellisense Off”


            If x And ISENSE_FLAGS.ISENSE_NOBG Then

                result = “No background parsing. “

            End If


                result = result + “No Intellisense queries in IDE. “

            End If

            If x And ISENSE_FLAGS.ISENSE_NCBRO Then

                result = result + “No saving of NCB file. “

            End If

        End If


    End Sub

    Sub DeleteNcbAndReload()

        Dim name

        Dim namesln

        namesln = DTE.Solution.FullName()

        If Len(namesln) > 4 Then

            name = Left(namesln, Len(namesln) – 4) & “.ncb”

        & nbsp;   If MsgBox(“This may take a while.  Closing solution, deleting ” & name & “, and reopening solution.”, MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then



                MsgBox(“NCB deleted”, MsgBoxStyle.OkOnly)


            End If


            MsgBox(“No solution is currently loaded.”, MsgBoxStyle.OkOnly)

        End If

    End Sub

End Module


Posted in C++


Discussion is closed.

Feedback usabilla icon