12

I'd like to map the ReSharper_ToggleSuspended command to a button on a toolbar in VS 2012, but the command is not listed in the ReSharper category of Commands availabe in Customize > Commands dialog.

Is there a way to do this?

Faust
  • 15,130
  • 9
  • 54
  • 111
  • 2
    See http://stackoverflow.com/questions/15394784/adding-a-visual-studio-toolbar-button-for-a-command-that-is-only-available-as-a and the comment about Visual Commander for VS 2012 – Sergey Vlasov Sep 28 '13 at 05:22

2 Answers2

28

Borrowed from the suggestion on the R# issue tracker for this issue.

In the VS Package Manager Console, you can run these commands to add the ReSharper_ToggleSuspended command to an existing toolbar named "R#".

$cmdBarName = "R#"
$cmdName = "ReSharper_ToggleSuspended"
$cmdText = "R# Active"
$toolbarType = [EnvDTE.vsCommandBarType]::vsCommandBarTypeToolbar

#----If you have a command bar you want to use---
#$cmdBar =  $dte.CommandBars.Item($cmdBarName)
# - or you can create one -
$cmdBar = $dte.Commands.AddCommandBar($cmdBarName, $toolbarType)
#------

$cmdItem = $dte.Commands.Item($cmdName).AddControl($cmdBar, 1)
$cmdItem.Caption = $cmdText

enter image description here

You can use any existing toolbar, or create one from scratch. I had originally added a new toolbar using the UI but updated this to include how to create one, as well as to update the Button text to use $cmdText.

Rick Strahl has a decent writeup on the command bars, if you are interested.

StingyJack
  • 19,041
  • 10
  • 63
  • 122
2

I think that the Resharper_ToggleSuspended command relates to the 'Suspend' button under Tools->Options...->Resharper->General. It seems you can't have items from the Options dialogue as commands. Possibly your only choice is to assign a keyboard shortcut to it.

Piers Myers
  • 10,611
  • 6
  • 46
  • 61