Is there a setting in Visual Studio 2008 that I can turn on which would generate a matching closing brace for a opening brace?
EDIT: I would imagine that an IDE as p
I use ReSharper. It does a whole lot more besides just the closing brace. The only downside is it's not free. But give it a try. The code analysis is worth the price anyway.
Most of the time, you can use autocompletion and code snippets.
If you want to write a for loop, just type "for" and then TAB. VS will complete it (including the braces).
Same thing for if, struct, class, switch... You don't even have to type the first brace !!
Good paper about it here : https://web.archive.org/web/1/http://blogs.techrepublic%2ecom%2ecom/programming-and-development/?p=655
Depends on what you are looking for VS does have some standard auto completion if[tab][tab] and for[tab][tab] try[tab][tab](and lots of other constructs) will get you more than the matching braces in a really nice fashion.
If you don't want to pay for ReSharper or a similar package, I made a free extension to automatically close braces. You can find it in the Visual Studio Gallery at http://visualstudiogallery.msdn.microsoft.com/en-us/0e33cb22-d4ac-4f5a-902f-aff5177cc94d. It will only work in Visual Studio 2010 though.
In VS 2013 there is the option of "Automatic delimiter highlighting" (under tools, options, text editor) and while checking that box should highlight matching braces, it doesn't under default settings. This is because the default background is white, and the default highlight color is also white. This can be changed by going to environment, fonts and colors, and changing the background color of "brace matching (rectangle)". Then matching braces will be highlighted and visible.
I realized after I answered that the question was creating the brace not being able to find existing braces. As that's the question I was trying to answer when I ended up here I'm leaving the answer in case it's helpful.
I know the original question is about VS2008, but I'm putting this here as info for other people and to make it useful for recent versions
The Productivity Power Tools (available for VS2010 and VS2012) extension now supports automatic brace completion.
If you already have it installed for VS2010, you must update to at least version 10.0.10710.22. Click
Tools -> Extension Manager -> Updates
Once you have it installed, you can turn brace completion on or off by going to
Tools -> Options -> Productivity Power Tools -> All Extensions -> Automatic Brace Completion
The most recent version now provides the ability to turn of any features you don't like so you can configure it to your requirements
Even though there's a matching addin for Visual Studio 2013 as well, VS now has native support for automatic brace completion without using any addins. Just go to:
Tools -> Options -> Text Editor -> C#
Tick checkbox against Automatic brace completion