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

前端 未结 1 1559
我在风中等你
我在风中等你 2021-01-05 23:21

This question relates to this ReSharper YouTrack issue.

In Visual Studio 2010 with ReSharper 7.1.1 installed, if I go to Tools > Options > Environment > Keyboard, th

相关标签:
1条回答
  • 2021-01-05 23:57

    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.

    0 讨论(0)
提交回复
热议问题