Studio中删除键盘快捷键绑定

Studio中删除键盘快捷键绑定

本文介绍了使用宏在Visual Studio中删除键盘快捷键绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了许多自定义键盘快捷键.为了避免每次安装新的Visual Studio时都必须进行设置(目前很多情况,VS2010在beta/RC中),我创建了一个宏,用于设置所有自定义命令,如下所示:

I have a lot of custom keyboard shortcuts set up. To avoid having to set them up every time I install a new visual studio (happens quite a lot currectly, with VS2010 being in beta/RC) I have created a macro, that sets up all my custom commands, like this:

DTE.Commands.Item("ReSharper.ReSharper_UnitTest_RunSolution").Bindings = "Global::Ctrl+T, Ctrl+A"

我的主要问题是,默认情况下,将Ctrl + T设置为映射到transpose char命令.所以我想在宏中删除该默认值.

My main problem is that Ctrl+T is set up to map to the transpose char command by default. So I want to remove that default value in my macro.

我尝试了以下两行,但都抛出异常

I have tried the following two lines, but both throw an exception

DTE.Commands.Item("Edit.CharTranspose").Bindings = ""
DTE.Commands.Item("Edit.CharTranspose").Bindings = Nothing

尽管它们很有效,因为它们实际上删除了绑定;),但我更希望不会抛出异常的解决方案.

Although they kind of work, because they actually remove the binding ;) But I would prefer the solution that doesn't throw an exception.

那是怎么做的?

推荐答案

我已经解决了同样的问题.我使用宏为一组对齐宏分配键绑定.

I have coped with the same issue. I use a macro to assign key bindings for a set of align macros.

Dim NewBindings() = {"Global::Alt+="}
DTE.Commands.Item("Macros.Dev.AlignUtils.AlignEquals").Bindings = NewBindings
NewBindings(0) = "Global::Alt+Num -"
DTE.Commands.Item("Macros.Dev.AlignUtils.AlignMinus").Bindings = NewBindings
...

要删除键绑定,我使用以下语句:

And to remove key bindings i use the following statements :

Dim DelBindings() = {}
DTE.Commands.Item("Macros.Dev.AlignUtils.AlignPlus").Bindings = DelBindings

在Visual Studio 2005下可以正常工作.

It works fine under Visual Studio 2005.

这篇关于使用宏在Visual Studio中删除键盘快捷键绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 09:31