How to add Close All But Pinned command to Visual Studio 2010 menu or toolbar? - visual-studio-2010

I've implemented the suggestions in Scott Hanselman's blog post Simplify your Visual Studio 2010 Toolbar and Free Your Mind. Very cool.
Where can I find/execute the command "Close All But Pinned" that is part of Visual Studio Productivity Power Tools.

You can assign a shortcut in Tools -> Options -> Environment -> Keyboard. Search for Window.CloseAllButPinned in the Show commands containing: textbox and assign your own key combination.
Similarly, you can execute that command in the "Go To Find Combo" small box, i.e. press Ctrl+/ then type ">Window.CloseAllButPinned", press Enter.

It is a two step process:
Create a Macro with the following
Public Module myToolbar
Sub CloseAllButPinned()
DTE.ExecuteCommand("Window.CloseAllButPinned")
End Sub
End Module
Right click on your Toolbar, choose Customize, Add Command, Category Macro, choose MyMacros.myToolbar,CloseAllButPinned
Then click ModifySelection and give it an easy to remember name

Related

Assigning a shortcut to Visual Assist's quick actions

In plain Visual Studio there is the Alt+Enter shortcut, which brings up a popup with quick fixes and improvement suggestions.
I am using the Visual Assist plugin for c++ development, which lets me right-click on a item and open 'Quick Actions and Refactorings (VA)' menu.
I would like to combine these two options into one: Having the advanced features in the easy accessible Alt+Enter shortcut without reaching to the mouse and right-click. Anyone knows how to assign a custom shortcut to 'Quick Actions and Refactoring'? Or any suggestions how to get rid of the tedious right-click?
Assigning shortcuts always works like this in Visual Studio:
Tools -> Options -> Environment -> Keyboard
Find the right identifier for the desired action, which is
VAssistX.RefactorContextMenu in your case.
Assign the desired shortcut Alt+Enter for the scope Text Editor and there you go.
Note, that this replaces Visual Studio's original Alt+Enter functionality, not blending them together.

Shortcut button for remote debugging in Visual Studio

I want to add a shortcut-button in Visual Studio 2015. Clicking this button should just emulate "Attach To Process" -> Select "w3wp.exe" -> Attach.
Does anyone know how to do it?
You can't do those two commands on one toolbar button click apart from creating or using an existing Visual Studio extension.
Creating a Visual Studio extension would be feasible but somewhat involved (as a complete project in itself).
Available Extensions:
The first extension you could use is Visual Commander (detailed below) to create a Macro.
Depending on your needs you could also use AttachTo which provide a one click option to attach to IIS.
Finally there is also Debug Attach Manager which can attach to specific process and then remember it.
Using a macro to achieve the desired effect:
As mentioned by #Sergey Vlasov, you can can install a Visual Studio Extension named Visual Commander that brings back Macros in Visual Studio. Then you can program a macro to do this for you. The code for the macro comes from another SO answer
Public Sub AttachShortcut()
For Each proc In DTE.Debugger.LocalProcesses
If proc.Name = "what you're looking for" Then
proc.Attach()
Exit Sub
End IF
Next
End Sub
Adding the shortcut button:
You can also easily add a button in your toolbar to add "Attach to Process..." if you prefer to have the button on your toolbar.
To do this go in the Menu under TOOLS. Then choose Customize.
There select the second tab "Commands".
The select Toolbar and choose the toolbar you want the button to appear in. For example "Debug" if you want it to appear during debugging.
Then press the Add Command... button and choose the Debug category. There you will find the Attach to Process.
This would make it more readily available if you prefer to use the toolbar.

How to run debug on a project selected in Solution Explorer with a key combo?

Is there a way to bind a shortcut that will run a project that is currently selected in the Solution Explorer (that is not the startup project of the current solution) in Visual Studio 2010?
I couldn't find any actions related to Solution Explorer specifically in Options > Environment > Keyboard section.
Find this msdn doc http://msdn.microsoft.com/en-us/library/aa301747(v=vs.71).aspx, it already explains quite clearly. If you have any more doubt, we can discuss it further.
Update:
I've done this on my computer with Visual studio 2010.
After seeing this dialog, choose an action from the drop down lists under the Show commands containing, in your case, choose Debug.Run. Then choose global in the Use new shortcut in list, and in the Press shortcut keys your customized shortcut key, for example Alt+r, press Assign. Press OK.
After all the settings, I press Alt + r, my selected project compiles and runs, just the same as the menu Debug->Run.
Hope I've made myself clear for your solution.

How to Restore Navigate To Dialog in Visual Studio After Resharper Installation

After installing Resharper 7.1.2 for Visual Studio 2010, when I press Ctrl+, I no longer see the Navigate To dialog. Instead a Resharper dialog Recent Files appears. My question is, is there another key binding that I am not aware for the Navigate To dialog or how can I configure Resharper/VS to show the Navigate To dialog upon pressing Ctrl+,. In the Resharper options I have selected Visual Studio for the key bindings since that is what I am accustomed to, but for some reason this one has changed.
It sounds like you will need to remove the ReSharper keybinding and add the Visual Studio one again. Try the following:
From Visual Studio 2010, go to Tools -> Options -> Environment -> Keyboard.
In the textbox below "Show commands containing:" enter "gotorecent".
This should bring up one match and you can see the Ctrl+, shortcut applied:
Click the Remove button. This should remove the keybinding.
In the textbox below "Show commands containing:" enter "edit.navigateto" (or for VS2017 "edit.gotoall").
This should bring up two matches. We are only concerned with the first one so make sure it is selected.
Click the texbox below "Press shortcut keys:" and press Ctrl+,
Click the Assign button.
Click the OK button.
You may have to restart Visual Studio but that should do it.
Edit: Just in case it helps anyone else, in order to track down the command names, I exported the keyboard settings via Tools -> Import/Export settings -> Export selected environment settings -> select only Options -> Environment -> Keyboard.
In the resulting .vssettings file, the Command attribute of each Shortcut element contains the text that should be typed into the "Show commands containing:" textbox.
It should be noted that the command for ReSharper's navigate to dialogue is "Ctrl + T"
In Visual Studio 2017, you need to assign Ctrl+, to Edit.GoToAll (rather than Edit.NavigateTo).
UPDATED:
Go to the Options->Environment->Keyboard, Make sure that (Default) is chosen in the top dropdown, type in Edit.GoToAll in the "Show comands..." textbox. Remove the existing shortcut. Type Ctrl+, in the "Press Shortcut Keys:" textbox. Click assign.
#Malice explained really well, but here is just one more tip:
When you are in the Keyboard Options menu, you don't need to export all commands in order to see which command corresponds to a particular shortcut, you can click on the "Press shortcut keys" text box and type your keyword to see what it is assigned to.
So you could:
go to the Keyboard Options menu,
type Ctrl+, to see what it is assigned to,
unassign it,
then type Ctrl+T to see what that "Navigate To" dialog is called within VS
reassign that function to Ctrl+,

How does one set Visual Studio 2010 keyboard shortcuts comfortably, especially when using ReSharper?

In every Visual Studio.NET version you can set keyboard shortcuts using menu Tools -> Options -> Environment -> Keyboard and then find the command you want to assign a shortcut to by entering part of it in "Show commands containing".
For one thing, the listbox is ridiculously short and hard to navigate - is there an alternative?
Then, how do I find out the correct command name for a specific action?
Specifically, I'm using ReSharper 5.1 with Visual Studio 2010 and want to have the Alt + Enter shortcut back (it used to be there in older versions by default) that opens the ReSharper context menu when the cursor is over a curly underline ReSharper uses to highlight errors or warnings.
How do I find out the command name for that (except by an educated guess)?
The way I do this is to perform an action while recording a macro (using Tools / Macro / Record temporary macro).
When I have finished with the action, I look at the source code of the macro and it usually helps to find the correct command.
For example, I have just let R# add some magic through Alt-Enter, and the macro recorder has:
DTE.ExecuteCommand("ReSharper_QuickFix")
You can rebind all of the ReSharper shortcuts by using the ReSharper -> Options -> Visual Studio Integration page. Select a keyboard scheme and hit "Apply Scheme".

Resources