Can't create macro in Visual Studio 2010 - visual-studio-2010

I did this before but now I am unable to do it again.
I want to create a macro and short cut to untabify selected lines.
First , I select the lines I want to untabify.
Then I choose record temporary macro.
Then I select Edit - Advanced - Untabify Selected Lines.
Then I click stop recording.
In the Macro Explorer I have "TemporaryMacro" but if I undo my last action and run the macro, it doesn't do the untabify.
Here is the macro code:
Sub TemporaryMacro()
DTE.ActiveDocument.Selection.Untabify()
End Sub

This problem was caused by windows update KB2898869.
Uninstalling it allows macros to work again in Visual Studio.

Related

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.

Shortcut to change which statement is executed next

When debugging in Visual Studio, I can change the line of next execution by dragging the yellow arrow to the desired line.
Is it possible to put the cursor on a line and use a shortcut to do this instead of dragging?
I'm using Visual Studio 2008 at the moment, but this can be done by right-clicking on the source and selecting "Set Next Statement" from the popup menu. I would be surprised if this has been removed from VS2010.
If that's not short enough for you, you can go into "Tools" -> "Customise" and set up a keyboard shortcut to the "Debug.SetNextStatement" command. On my current setup (perhaps not the default), you can press CTRL+SHIFT+F10.

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

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, there is a command called ReSharper_SilentCleanupCode.
I would like to bind this command to a toolbar button.
This seems to be impossible using Tools > Customize > Commands because the only commands available within this dialog are for actions that already have an associated menu item. The particular ReSharper command I'm interested in (Silent Code Cleanup) doesn't appear in any menu, so it cannot be assigned to a toolbar button using the "GUI".
Is there any other way to bind a keyboard-only command to a toolbar button? (One of ReSharper's programmers thought the "VS script editor" could be used, but I'm not having any luck finding info on this.)
Edit
I should have mentioned this in the first place. While azhrei's macro solution is great for Visual Studio 2010, it will break once I upgrade to VS 2012, because macros are no longer supported. If someone has a solution that will continue to work in VS 2012, that would be preferable. (Or perhaps VS 2012 toolbars don't have the same limitation in the first place?)
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.

visual studio 2010 confirmation on close

I want VS2010 to ask me when I am closing the whole environment whether I am sure about closing VS2010 or not.
Unfortunately I couldn't find this setting anywhere
Anybody knows?
AFAIK, there is no such option. However, there is an old tool called NoClose that can disable the (X) button for you (see LifeHacker article about this tool)
Though I haven't used it under Windows 7/8, I'm not sure if it is compatible.
I haven't tried this in Visual Studio 2010, but you can achieve this in Visual Studio 2008 at least by using an Automation Macro. The instructions below work for 2008, and shouldn't be too hard to translate to 2010 (hopefully).
Open up the Macro IDE (Tools->Macros->MacroIDE), and in the list of Macros you should see an item EnvironmentEvents. Double-click this to get a module containing the existing Environment Event macros.
In the drop-down list select SolutionEvents, and then in the Declarations list select QueryCloseSolution. What we're doing is creating a macro that is run whenever you try to close a Solution. We'll create a messagebox to ask the user if they really want to do it, and optionally cancel the shutdown - you should end up with something like this:
Private Sub SolutionEvents_QueryCloseSolution(ByRef fCancel As Boolean) Handles SolutionEvents.QueryCloseSolution
If (MsgBox("Close the solution?", MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel) Then fCancel = True
End Sub
Save the Macro project, and try closing the solution, or shutting down Visual Studio. If the stars are aligned you'll see a confirmation message box. If you click "Cancel", the solution won't close, and VS won't shut down.
Now, perhaps someone can confirm in the comments if this works for VS2010?

Can Visual Studio Automatically Expand Text with a Code Snippet?

In Delphi if I type "if" and space it automatically inserts the code snippet with an if statement block defined. I know in Visual Studio I can insert a snippet, but I have to either right-click and select "insert snippet", or hit CTRL-K followed by CTRL-X.
Is there a way to configure Visual Studio to automatically insert the snippet like Delphi does?
Press tab tab.

Resources