Question :
How do I make Visual Studio auto generate braces for a function block?,
Answer :
I could swear I’ve seen people typing function headers and then hitting some key combination to auto-create function braces and insert the cursor between them like so:
void foo()_
to
void foo() { _ }
Is this a built-in feature?
,
The tools look nice (especially Resharper but at $200-350 ouch!) but I ended up just recording a macro and assigning it to ctrl+alt+[
Macro came out like this:
Sub FunctionBraces() DTE.ActiveDocument.Selection.NewLine DTE.ActiveDocument.Selection.Text = "{}" DTE.ActiveDocument.Selection.CharLeft DTE.ActiveDocument.Selection.NewLine(2) DTE.ActiveDocument.Selection.LineUp DTE.ActiveDocument.Selection.Indent End Sub
Edit: I used the macro recorder to make this and it wasn’t too bad
That’s the answer How do I make Visual Studio auto generate braces for a function block?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.
Disclaimer :
The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you