使用宏在 Visual Studio 中删除键盘快捷键绑定
我设置了很多自定义键盘快捷键。为了避免每次安装新的 Visual Studio 时都必须设置它们(这种情况经常发生,VS2010 处于 beta/RC 版本),我创建了一个宏,用于设置所有自定义命令,如下所示:
DTE.Commands.Item("ReSharper.ReSharper_UnitTest_RunSolution").Bindings = "Global::Ctrl+T, Ctrl+A"
我的主要问题是 Ctrl+T 默认设置为映射到转置 char 命令。所以我想删除宏中的默认值。
我尝试了以下两行,但都抛出异常
DTE.Commands.Item("Edit.CharTranspose").Bindings = ""
DTE.Commands.Item("Edit.CharTranspose").Bindings = Nothing
虽然它们有点工作,因为它们实际上删除了绑定;)但我更喜欢不抛出异常的解决方案。
这是怎么做到的?
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"
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.
How is that done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经处理过同样的问题。我使用宏为一组对齐宏分配键绑定。
为了删除键绑定,我使用以下语句:
它在 Visual Studio 2005 下工作正常。
I have coped with the same issue. I use a macro to assign key bindings for a set of align macros.
And to remove key bindings i use the following statements :
It works fine under Visual Studio 2005.
我遵循了一种更务实的方式(使用您的示例):
在第一个分配中,
Ctrl+T
未从任何其他函数分配,然后与第二个分配解除绑定。对我来说就像一个魅力。
I followed a little more pragmatic way (using your example):
With the first assignment
Ctrl+T
is unassigned from any other function and then becomes unbound with the second assignment.Works like a charm for me.
您不需要使用宏来更改它,只需进入
菜单>工具>选项--键盘,然后从下拉列表中选择您想要更改的快捷方式并分配您想要的快捷方式
You do not need to change it with macro, Just go to
Menu>Tools>Options -- Keyboard and then select what you want to change the shortcut from the dropdown and assignyour desiered short cut