Matching a closing brace in Visual Studio - visual-studio

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.

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
VS 2010 and VS 2012
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
VS 2013
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.

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

EDIT: Thanks hyde, Steven's answer appears to be right: The Microsoft Productivity Power Tools do have a 2012 version now.
Original outdated answer:
It appears that the Microsoft Productivity Power Tools don't work in VS 2012 yet. If you're looking for a solution that works on the new version, you can check out this extension:
http://visualstudiogallery.msdn.microsoft.com/0e33cb22-d4ac-4f5a-902f-aff5177cc94d

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.

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.

Late to the party here, but I guess you got use an independently running AutoHotKey script to insert closing brackets/quotes for you.

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.

Related

Curly braces sizes mismatch in Visual Studio 2022

it happened after I installed Productivity Power Tools extension. It seemed not work with C++, so I deleted it. But after deletion, I noticed this "bug". I'm not even sure if it's extensions problem, but I really don't like it
This is probably down to the Shrink Empty Lines extension which is part of the Productivity Power Tools suite. You can configure it under Tools->Options...->Productivity Power Tools

How to turn off double quotes auto-completion in Visual Studio 2019 for C++ editor?

After updating to version 16.1 of Visual Studio 2019, the code editor for C++ completes double quotation characters. When I type one double quote " it automatically completes it as "".
How to turn this feature off? I tried to look into settings, but could not find in C++ Editors settings or All Languages settings.
Update: it actually only completes when I type wide string literal starting with L. For example, when I type L" it auto-completes it to L""
Update 2: it happens for some .cpp files but not for others. I currently do not see any pattern. Seems like a bug.
Double quote auto-completion is disabled when automatic brace completion is disabled.
You can disable that in the Tools->Options->Text Editor->C/C++->General menu.
As noted in one of the other answers, that option doesn't work properly in some older versions of Visual Studio 2019.
Update October 2019: it is fixed now starting from version 16.3.2. If not, then check your settings carefully.
Short version: This is a bug in Visual Studio, and hopefully will be fixed. You can up-vote it here.
Longer version:
I decided to report this bug to Visual Studio Team, but someone already did that. So if you are affected by this issue, consider up-voting it.
Link to VS bug tracker: Brace completion when member list is up does not put the character in the right position
Note, that while title of above bug may sound like only Code Analysis is affected, VS Team have marked another - more relevant bug as a duplicate to the above bug (C++ automatic quote completion). And it is not possible to vote closed bug, so only option is to vote the first one I mentioned.
I'm using VS 2019 Community Verssion 16.3.9 and have found that when the marker is in the string, the (Ctrl + Shift) combination toggles automatic double-quote placement on and off.

Resharper Overriding VS Functionality

I downloaded the trial of Resharper and installed it today. The first thing it asked me was that version of shortcut keys I wanted to use. It asked me if I wanted to override some standard Visual Studio shortcut keys. My answer was ##$# no!
However, the first thing I did was a Ctrl-Dot on a class reference that was missing an import. Immediately, the Resharper context menu came up which is similar to the VS one, but is missing the item for automatically adding the import.
How do I keep Resharper from usurping VS functionality?
Edit: Ouch! After using this thing for a couple of hours, I've realized that it has totally overridden loads of VS functionality. This thing is awful. I just want to use the toolset, I don't want a completely new IDE. If I wanted a different IDE, I'd go out and buy one. How do I turn off all Visual Studio integration except for the menu that lets me run the tools?
There are a lot of different settings you can turn on and off to allow Visual Studio to behave more like Visual Studio when Resharper is in action. What's I've learned to do is just turn it on when I want to use it, and turn it off when I want to use Visual Studio.
Tools -> Options -> Resharper Ultimate General -> Suspend / Resume Now

Enabling opening and closing tag guidelines in Visual Studio

I've recently started using Visual Studio quite heavily since starting to develop in .Net
I really like the intellisense as it increases my productivity by allowing me to code faster. Previously when authoring CSS I would just use Notepad ++ and I got very used to some of the little features that this awesome text editor possessed however, now that I am doing the bulk of my work in Visual Studio 2013 I want to try and avoid having too many environments open at once. With this in mind, there is one feature inparticular that I would like to try and replicate in Visual Studio when editing CSS or indeed any other type of code.
In Notepad ++ it automatically includes a sort of guideline which runs down the page between the opening and closing tags of elements as shown below:
My question is, how do I replicate this behaviour in Visual Studio 2013 as the currently setup I have at the moment isn't as clear/productive as you can see below:
Any help would be greatly appreciated.
There are a couple of free extensions you can use to do this. These will run on any of the Visual Studio versions except Express, which does not support extensions.
You can duplicate this with the Indent Guides extension.
You can also use the Structure Visualizer Feature of the Productivity Power Tools.
Note: The backgrounds in the example are different because they are taken on different machines with different themes.

Using CamelHumps without resharper or coderush

I've read through the previous threads on ctrl+arrow or ctrl+shift+arrow in visual studio using resharper or coderush.
There was one answer where a macro achieved the same result.
However, VS2013 no longer supports macros.
Is there an alternative way to support camelhumps in Visual Studio 2013 without relying on resharper or coderush?
I stumbled across this question before stumbling over the VSTricks extension, which does this (and a couple of other things).
After installing, I had to re-map the hotkeys manually, but it was pretty simple:
For all the settings in the list, I mapped to the keystrokes that were previously mapped to the corresponding commands for words (e.g. Edit.SubWordNext was mapped to Ctrl+Right arrow, which was previously mapped to Edit.WordNext).
The extension works in VS2015 too - and, unlike e.g. ReSharper which also has this feature, it's free :)

Resources