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 powerful as Visual Studio would have this very useful feature.
EDIT: Is there a macro that can be written? From the responses I have received it looks like ReSharper is the only option. I don't want to have to ask my company to invest in the ReSharper tool, I work for a rather large enterprise and getting anything approved from procurement is not an easy task.
EDIT: I am using VS 2010 Ultimate. The Power Tools and Power commands now do everything I was looking for in this post.
In this case you can simply press Ctrl + Shift + . to go to elements before or after the current element.
Bracket-matching provides visual cues illustrating the location of matched pair elements. With bracket-matching enabled, positioning the cursor on one paired element highlights the matching element in the code sequence.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With