Controlling IntelliSense Through Macros

Controlling IntelliSense Through Macros

  • Comments 14

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 files 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"

            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


Leave a Comment
  • Please add 6 and 6 and type the answer here:
  • Post
  • PingBack from

  • great !

    So, even in VS2008, there isn't any option to control this from the GUI ? That's a pity.

  • DeleteNcbAndReload???? vs. actually fixing the Intellisense? Big, huge, fat *SIGH*...

  • John they are fixing intellisense or as I heard rewriting. In the mean time this can help.

  • Dear Visual C++ architects:

    It would be really great if actual buttons were made in the Visual C++ interface to control intellisense, rather than providing macros behind the scenes. Visual Studio is at its best for huge projects, that's where the power of VS over conventional IDE's and text editors shows up, so please provide the controls in the GUI to make working with huge projects comfortable: intellisense isn't efficient for those, accept it and make a button to turn it off when needed. If possible, put it in a separate thread so that my VS2005 GUI doesn't stop responding for 15 minutes while I have unsaved files open. Sorry if it already is in a separate thread, then there must be another explanation why this gui not responding for 15 minutes thing happens.


  • Is there any way can let me read the NCB file?

    Or how can I get the origin definition of a MACRO by code?(e.g.:LPTSTR's origin definition is wchar_t *).

    Thank you very much.

  • You guys heard of Visual Assist X, did you? This is much more than an enhanced IntelliSense and it doesn't rely on the browse file mechanism, so it works with driver projects as well or other projects which are based on make files, but have the concept of a common include path and source path and so on.

    Worth every penny!

    But regardless: thanks for VS2008! It's a great product, although I just started exploring it ;) (via MSDN Pro, so it's the Pro version I talk about)

  • Hello Last week, Jim announced the availability of the Intellisense fixes as a publicly downloadable

  • Hello Last week, Jim announced the availability of the Intellisense fixes as a publicly downloadable

  • im working on small projects - but, im noticing a huge improvement.  i recently got back into C++ from C#, and the intellisense was the one area that was painful compared to .NET (i understand why its harder with native code, so im not complaining).


  • Thank. This is exactly what i wanted

  • Is there any way to change the location of the NCB file? I'd very much like to move it to a temp or configuration specific directory.


  • When I run all the macros, I encounter "Value does not fall within the expected range" error. How do I fix this?

  • OMG.QFE.GDR.WTF?!!  Please go back to the sensible system -- which we all understand -- of naming things "beta" or "alpha" because this new system is confusing.

Page 1 of 1 (14 items)