如何关闭VS2008的intellisense

VS2008的intellisense每次更新时都会占用大量的CPU,对于在虚拟机里面开发来说,这个真的很难忍受,有时候开了三四个debug的时候突然更新一下,整个虚拟机都卡住半天。

    由于没找到相关的设置按钮,所以上网查了一下解决办法,中文查出来的方法只有一个,删除某个dll文件,但是下面同样注明了这种方法将导致无法添加atl简单类之类的副作用。详情:http://hi.baidu.com/hxb631/blog/item/bf1d1310aaaee15ecb80c4aa.html

   中文查出来的东西大都是一些垃圾,所以用谷歌搜索了一下。虽然很多东西都打不开,但是还是找到了一个链接:http://blogs.msdn.com/b/vcblog/archive/2007/11/19/controlling-intellisense-through-macros.aspx

这是VS的一个工程师给出的解决办法:用宏来关闭intellisense的更新。

   下面是解决办法的原文:

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.

翻译:

1.在“Tools|Macros|Macro Explorer”下打开Macro Explorer。

2.点击Macros节点,选择 “New Macro Project”  ,取名为“Intellisense”,然后选一个位置保存(默认位置即可)。

3.你可以看到一个宏工程,名字叫做Module1,通过右键的rename将其名字改为IntellisenseModule(程序员就是有拼写强迫症。。。其实随便取个名字也没什么问题)。

4.  右键选择Edit,然后会打开一个新的窗口。将表1中的文字复制到窗口,然后选择“File|Close and Return” (我没找到这个选项,直接点了保存,然后点了绿色的小三角形运行了一下,然后关闭窗口,关闭时会提示是否停止debug)

5.现在宏代码已经都有了,只需要把宏代码添加按钮位置即可(可以看到这段宏代码一共定义了四个操作,分别是:不更新关闭开启,当前状态,当然,这些跟设置没关系)。

6.未完待续


Figure 1

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值