TheRevanchist
TheRevanchist

Reputation: 331

Closing Brackets Visual Studio

I am working in Visual Studio 2008 in C# programming language. I am having a big problem in it, because when I am opening a bracket the Visual Studio is not automatically closing it as usual. I am having great difficulty on it in big methods which contains many brackets (if else/for).

Any help is very much appreciated!

Upvotes: 0

Views: 1249

Answers (3)

Bruno Silva
Bruno Silva

Reputation: 3097

I suggest you install Productivity Power Tools or Resharper. Both these extensions have support for that.

Upvotes: 2

Mark Byers
Mark Byers

Reputation: 838666

A good strategy is to type the brackets in pairs first:

public void foo()
{
}

Then add the content:

public void foo(List<int> values)
{
     foreach ()
     {
     }
}

There are keyboard shortcuts that allow you to do this faster. Try typing foreach then press Tab twice.

If you still manage to get confused it might be because your methods are too long. You can refactor your code into smaller methods. Use the "Extract Method" refactoring tool to help you do this.

You may also want to occasionally "Format Document". This will line up the braces for you, and indent your code. This will make it more obvious which braces match up.

You might also want to consider installing a third party extension such as Resharper.

Upvotes: 8

alc
alc

Reputation: 1557

Have you tried the Productivity Power Tools? It looks like they added automatic brace completion in 10.0.10710.22.

Upvotes: 2

Related Questions