Adding a Visual Studio toolbar button for a command that is only available as a keyboard shortcut

无人久伴 提交于 2019-11-30 22:48:33

Add a macro that executes the command, then add the macro to a toolbar.

This works because it makes the keyboard-only command appear in the Macros menu in the Customize Commands dialog.

Details

Add a macro which does this:

    Sub _ReSharper_SilentCleanupCode()
        DTE.ExecuteCommand("ReSharper_SilentCleanupCode")
    End Sub

Put this macro in a module which appears in Customize..Commands..AddCommand..Categories..Macros, such as Samples or MyMacros.RecordingModule, but not MyMacros.Module1 (the default when using the macro IDE).

Go to Tools..Customize..Command and select the Toolbar you want.

Now Add Command... and select the Macros category.

Select your Macros.Samples._ReSharper_SilentCleanupCode macro.

Click Modify Selection and change the name to #-) or whatever text makes you think ReSharper Silent Code Cleanup without being too long for your toolbar. :-)

I tried this with Visual Studio 2010 and ReSharper 7.1.2.

Edit

Visual Commander is a apparently way to get this going on VS2012 as well - see comments below for more.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!