Reputation: 109
In Visual Studio 2012 I created a macro to create an open curly brace, create a new line, create a new line, create closing brace and move cursor one line up followed by a TAB.
That macro was associated with a Ctrl + 0 so that after Ctrl + 0 I was ready to write code.
How can I do the same in Visual Studio 2012 which doesn't have my macro?
Upvotes: 2
Views: 538
Reputation: 109
This is what I added to the wizard created prj: The install it in VS2012 and associate key combination: SHIFT+ALT+0
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "CurlyBraces.Connect.CurlyBraces")
{
if (_applicationObject.ActiveDocument != null)
{
TextSelection objSel = (EnvDTE.TextSelection)(_applicationObject.ActiveDocument.Selection);
objSel.NewLine();
objSel.Insert("{"); objSel.Indent();
objSel.NewLine();
objSel.NewLine();
objSel.Insert("}"); objSel.Indent();
objSel.LineUp();
objSel.Indent();
objSel.SmartFormat();
objSel.LineUp();
}
}
}
}
Upvotes: 1
Reputation:
This is a free download from Visual Studio Gallery from the MSDN. I think you'll find this does the trick.
http://visualstudiogallery.msdn.microsoft.com/8e2103b6-87cf-4fef-9410-a580c434b602
Upvotes: 0