I'm working on an open source project that uses horizontal alignment in source code. The code is written in C++, and I'm using Visual Studio 2013. Visual Studio tries to be smart concerning spacing, but ends up destroying my manual alignment.
A typical piece of code looks like this:
bool → → → GetFieldWithType → → ( int idx, cc8* name, int type );
bool → → → GetFieldWithType → → ( int idx, int key, int type );
static cc8* → GetLuaTypeName → → ( int type );
void* → → → GetPtrUserData → → ( int idx );
Now, if I add another line just like this, as soon as I type the opening parenthesis (after two tabs), Visual Studio removes the two tabs I just entered and replaces them with a single space. I try to be patient and hit Ctrl+Z to undo the automatic formatting. But as soon as I type the semicolon, it kills the tabs all over again.
I found an option in Tools > Options > Text Editor > C/C++ > Formatting > Spacing > Spacing for function parentheses that toggles whether to insert a space before the opening parenthesis of an argument list. If I deactivate this option, VS still insists on removing the tabs before the opening parenthesis, it just doesn't add a space. How do I get rid of this behavior?
To be clear: I'm fine with VS automatically inserting spaces (according to what I configured). I don't want to deactivate automatic formatting altogether. I just don't want it to remove the spacing I just manually entered.
Go to Tools > Options > Text Editor > C/C++
.
Under Tabs
you can change "Insert spaces" to "Keep tabs". If you don't want VS mucking up your indentation at all, you can also turn off indenting here.
Under Formatting > Spacing
you can uncheck (almost) all the "Remove space..." options.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With