本文译自: http://blogs.msdn.com/b/vcblog/archive/2007/11/19/controlling-intellisense-through-macros.aspx
当解决方案包含了很多个工程,越来越大之后,VS的智能提示经常会导致VS本身卡死。其实,当安装了VC助手后,VS的智能提示就可以不用开启了。
In general, these advanced settings should be unnecessary except for extremely large solutions or other special situations, especially given the improvements we recently implemented.
VS的一个工程师提供了一种通过宏(Macros)控制智能提示的方法:(以下操作使用的是英文版VS2008,其他版本或语言请自行对应。)
1. 进入Tools -> Macros -> Macro Explorer,右击”Macros”节点,选择”New Macro Project”。选择“Macro Project”,将其重命名为”Intellisense”,保存默认即可。这样就创建了一个名为”Module1”的模块,将其改名为”IntellisenseModule”。右击该模块,选择”Edit”,将会出现一个空模块窗口,然后将以下内容粘贴至该模块并保存退出。
Imports System Imports EnvDTE Imports EnvDTE80 Imports System.Diagnostics Enum ISENSE_FLAGS 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 If x = ISENSE_FLAGS.ISENSE_NORMAL Then result = "Intellisense On" ElseIf x = ISENSE_FLAGS.ISENSE_OFF Then result = "Intellisense Off" Else If x And ISENSE_FLAGS.ISENSE_NOBG Then result = "No background parsing. " End If If x And ISENSE_FLAGS.ISENSE_NOQUERY Then 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 MsgBox(result) 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 DTE.Solution.Close() Kill(name) MsgBox("NCB deleted", MsgBoxStyle.OkOnly) DTE.Solution.Open(namesln) End If Else MsgBox("No solution is currently loaded.", MsgBoxStyle.OkOnly) End If End Sub End Module
2. 进入”Tools -> Customize”,在”Toolbars”选项卡下,点击”New”,并将其命名为”Intellisense”。点击确定后,在右侧会有一个空的toolbar。再选择”Commands”选项卡,在左侧listbox中选择”Macros”,你就能看到你刚才建立的Intellisense宏了。将它们都拖到刚才的空toolbar中。
OK,你就能通过点击Intellisense Toolbar上的button,控制你的Intellisense策略了。
3. 对这五个选项的附加说明: