c++visual-studioformattingdesignated-initializer

Preserve indentation formatting when using C++20 designated initializers (VS2019)


Is there a way to get Visual Studio 2019 to preserve existing indentation when writing typing . to start typing the next field?

MyStruct a =
{
    .asd = 12,
.foo = 1,
}

While typing the following code, as soon as I type . for the foo field with the cursor right under . in the asd field VS removes all spaces and not even Ctrl + Z gets me back on the indentation I want.

I've gone through the extensive list of options in Text Editor > C++ > Formatting > Spacing but couldn't find one to disable this behaviour.


Solution

  • Turns out this was caused not by Visual Studio, but by the extension Visual Assist X. Disabling "Convert dot to -> in C/C++" (in Visual Assist Options > Editor) for some reason fixes this.