How to get curly braces autocompletion in Visual Studio 2012. C #
Solution 1
See this question on StackOverflow: Curly braces autocomplete in Visual Studio 2012
Basically either of the following free add-ins should do the trick:
- Productivity Power Tools 2012 (for Visual Studio Professional 2012)
- Brace Completer
Additionally you may find that code snippets can help in certain situations, e.g. typing if
followed by Tab will insert a boilerplate if statement and allow you to quickly enter the condition before hitting Enter to place the cursor inside. Similarly typing ctr
and pressing Tab will do the same for the class constructor. There is not one for methods included by default but it is possible to create custom snippets.
Solution 2
I use ReSharper which adds this behavior. I believe Visual Studio is relying on the user to enter the } to trigger formatting:
Chris_45
Updated on September 18, 2022Comments
-
Chris_45 over 1 year
In moste IDEs you can set so if you type for example>
if(isTrue) { //and when you hit enter here you get the } automatically
But I have not found where you get this behavior in VS Options. Is there an addon for this?
-
James P about 11 yearsIs it not just easier to do if followed by [Tab] which creates the whole block for you?
-
James P about 11 yearsI should clarify that I'm talking about code snippets. Also, pressing [Enter] after typing the condition puts the cursor inside the if statement.
-
Chris_45 about 11 yearsYes you are right in that case. But if you want to write a constructor or something else public MyConstructor() {//...
-
-
Chris_45 about 11 yearsAnd opens up with Microsoft Visual Studio Version Selector
-
James P about 11 years@Chris_45: Can you explain what you mean?