Question

I don't mind most of the way that VS2005 auto-indents (or auto-formats) my C++ code, but certain items I don't want it to automatically indent. Like #define statements for example. It takes them and shoves them all the way to the left side of the screen, no matter how deep into my scope I type them. That's really really annoying.

Is there some way to alter this behaviour, besides completely disabling auto-indent/format?

Was it helpful?

Solution

If you have only a few examples you want to change (and don't mind re-correcting the indentation when there are whole section or file reformats), you can change the indentation to what you want, then move off the line.

The formatted indentation will return, but you can Undo (Ctrl+Z) and the indentation you want will return. (Note I haven't actually tested this in the C++ editor.)

As long as you don't mind "correcting" the indentation every time you edit the line (and the other times the whole section is reformatted), this allows you to have some lines alternately indented.

OTHER TIPS

Try go to Options -> Text Editor -> C/C++ -> Tabs -> Indenting and change it to Block. When selected, new lines are automatically indented. The insertion point is placed at the same starting point as the preceding line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top