3

I would like to get this indentation when working with classes / structs:

class MyClass
{
    public:
        MyClass();
}

However the text formatting option only allows for either this:

class MyClass
{
public:
    MyClass();
}

or that:

class MyClass
{
    public:
    MyClass();
}

So it only considers the access modifier itself instead of the code after it. The problem with this is that it formats it everytime wrong again when I copy/paste or just want to format existing code. Is there any way around this without manually formatting it everytime again?

Julian
  • 41
  • 7

1 Answers1

1

It seems there is no way to do it when, under Tools->Options, Text Editor, C/C++, Tabs has Indenting set to Smart. Your class access specifiers will be automatically formatted in one of the two modes you already specified.

If you set Indenting to Block, they will be left untouched, so you're free to copy/paste your code without "smart" formatter intervention.

See: Indenting issue after access specifiers in Visual Studio Express and C++ access modifier auto indentation in visual studio 2010 slowly driving me crazy - can it be changed?

Community
  • 1
  • 1
Fab
  • 139
  • 11
  • If setting Indenting to Block, all other formations don't take place either, which is not what I want. Also couldn't find those posts by searching before asking... Could have saved this useless question then. Since vs12 there is no solution to this, which is a shame. Thanks for clearing it at least! Any future fix is highly appreciated. – Julian Aug 09 '15 at 21:13
  • Even with indentation set to Block, it still formats this for me in Visual Studio 2015. – Andrew Jun 11 '16 at 09:30
  • @Julian See my answer. – Andrew Jun 11 '16 at 09:45