The automatic indentation of the C ++ access modifier in Visual Studio 2010 slowly drives me crazy - can this be changed?

When programming C ++ in Visual Studio, he insists on giving me those terrible indents for access modifiers - my condolences if someone really likes them that way;) (joke guys!)

public class MyClass { public: MyClass(); ~MyClass(); int wowAnInt(); } 

Needless to say, I want this:

 public class MyClass { public: MyClass(); ~MyClass(); int wowAnInt(); } 


Is there a way to achieve this using something (I have ReSharper and Highlighter) or maybe Vanilla VS?

+8
source share
2 answers

The closest you can get with the built-in settings of the Visual Studio editor is to change the indentation mode from "Smart" to "Block" ("Tools" β†’ "Options" β†’ "Text Editor" β†’ "C / C ++ β†’ tabs β†’ Indent).

When you do this, you can backtrack on anything you like, you just lose the β€œauto-padding”. Basically, whenever you press [enter], the new line will be indented with the same number of tabs / spaces as the previous line, and it will not automatically reformat the lines to make them line up.

+9
source

There are two options you need to change to make the code look the way you want. (Based on Python, I am really worried if the material is not indented after the colon.)

I used the answer of James McNellis and changed it from Smart to Block, although I'm not sure how much this helped.

In the Tools β†’ Options β†’ Text Editor β†’ C/C++ β†’ Formatting β†’ Indentation β†’ Indent Access Specifiers , there is a setting that indentes for access specifiers, but does not indent them.

I also selected "Do nothing" in Tools β†’ Options β†’ Text Editor β†’ C/C++ β†’ Formatting β†’ General β†’ When paste didn't change just by copying / pasting. "

This is not an ideal solution, but at least a little closer.

+1
source

Source: https://habr.com/ru/post/887246/


All Articles