Rome_Leader
Rome_Leader

Reputation: 2700

My Brackets Will Not Autocomplete In Visual Studio

Whenever I type an opening bracket (square, curly, parentheses or otherwise), I am used to having its closing pair automatically generated by the compiler. At least, this was the case in my previous compiler. However, this doesn't happen for me in Visual Studio 2012. I've looked around in the options a bit, under Tools > Options > Text Editor > C++, but I can't seem to find an option to change this.

Can anyone suggest anything? Surely I am able to turn this feature on?

Upvotes: 0

Views: 4554

Answers (2)

Cedar Mora
Cedar Mora

Reputation: 13

A problem that I ran into for Visual Studio 2015 is that if there was an unbalanced bracket anywhere in the current file aka:

while(foo) {
    if(bar) {
}

then bracket autocompletion assumed that I was making a code block which was more deeply nested, which led to some odd behavior. If somewhere else in the file I tried to press enter to go from this (where the text cursor is represented by the pipe character( | ):

for(int i = 0; i < 5; i++) {|

to this:

for(int i = 0; i < 5; i++) {
    |
}

I would instead get this:

for(int i = 0; i < 5; i++) {
    |

So if your autocompletion isn't working in a single file, maybe check whether the braces in your file are balanced.

Upvotes: 0

Open your block, say :

void foo()
{

then hit Tab. I've been wondering this myself for some time and found it just today.

But I don't know if it is possible to have automatic () or [].

Upvotes: 1

Related Questions