VS 2005 C/C++ auto statement completion of if, case etc

Unanswered VS 2005 C/C++ auto statement completion of if, case etc

  • Tuesday, May 01, 2012 9:25 PM
     
     

    for years I have happily had VS automatically add opening paraenthesis when I hit the space bar after typing if or while and add : after I type case etc.

    This feature has suddenly stopped working and i cannot find for the life of me how to turn it back on. I'm sure it must be in the tools->options->text editor->C/C++ but cant see anyhting that looks like it may do the job.

    Anyone have any ideas?

All Replies

  • Wednesday, May 02, 2012 6:58 AM
     
     
    From what I know there is no standard support for this. Some plugins like Visual Assist however do so, may this be the case for you?
  • Wednesday, May 02, 2012 7:36 AM
     
     
    Not using Visual Assist or any other editing/formatting plug-ins that I'm aware of. Text editor using brief emulation but that's about it.
  • Wednesday, May 02, 2012 9:25 AM
     
     
    Hm, I cannot find the behavior you specifiy online. Please note that this will work for C# for example. May that be the case?
  • Wednesday, May 02, 2012 10:03 AM
     
     
    Yes agree, but this was for bog standard C/C++ projects not a C# proj. Most puzzling
  • Wednesday, May 02, 2012 10:40 AM
     
     
    Native C++, not C++/CLI perhaps? Just guessing, strange problem you have there...
  • Wednesday, May 09, 2012 6:27 AM
    Moderator
     
     

    Hi knowldav,

    I suggest you try the following steps:
    1->Select the code snippets you want to add opening parenthesis.
    2->Click Edit->Advanced->Format Selection.

    I hope this reply is helpful to you.
    Best regards,


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

  • Wednesday, May 09, 2012 7:20 AM
     
     

    No sorry that's not it - what I used to have was a form of intelligent formatting after pressing the space bar following a statement token the relevent syntactical punctuation was automatically inserted to aid typing the line of code. Example type "if<space bar>" then the editor would autoimatically add the opening parenthesis "if (" and if "case<space bar>" then the editor would insert a colon "case :"

  • Wednesday, May 09, 2012 9:57 AM
     
     

    No sorry that's not it - what I used to have was a form of intelligent formatting after pressing the space bar following a statement token the relevent syntactical punctuation was automatically inserted to aid typing the line of code. Example type "if<space bar>" then the editor would autoimatically add the opening parenthesis "if (" and if "case<space bar>" then the editor would insert a colon "case :"

    I believe, by this you mean statement completion feature. This is how it should work in VS 2005 - How-to: Provide Statement Completion "Traditional statement completion is invoked by pressing CTRL+<LEFT ARROW> or CTRL+SPACEBAR.". And this is for VS 2010 - Completion and Suggestion Modes.
  • Wednesday, May 09, 2012 10:06 AM
     
     
    Thanks for the suggestion, but it's not statement completion it acts more like Smart formatting, i.e, formatting the line of code with intelligent C like formatting rather than having any sense of variable scope, definitons etc. It is simply a type of smart simple formatting, nothing more exotic.
  • Wednesday, May 09, 2012 10:21 AM
     
     
    Thanks for the suggestion, but it's not statement completion it acts more like Smart formatting, i.e, formatting the line of code with intelligent C like formatting rather than having any sense of variable scope, definitons etc. It is simply a type of smart simple formatting, nothing more exotic.
    There are also Productivity Power Tools for retail versions of VS 2010 with nothing similar except for Auto Brace Completion option for VB.NET and C#. May be you have to check corresponding package for VS 2005.