How do I turn off auto-formatting in VS2013 for C++?

前端 未结 7 2073
一向
一向 2020-12-15 03:10

VS2013 has added auto-formatting for C++. My personal opinion on auto-formatting is that it\'s ultimately harmful for developers but I have to accept not everyone agrees. Wh

相关标签:
7条回答
  • 2020-12-15 03:23

    Just remember that resharper can also override the indentation/formatting settings. You can turn that off by doing this

    ReSharper -> Options -> Environment -> Editor -> Editor Behaviour -> Auto-format on closing brace (un-check this).

    0 讨论(0)
  • 2020-12-15 03:24

    It's a bug in VS 2013 beta that it cannot be turned off completely, see issue submitted by FuleSnabel: http://connect.microsoft.com/VisualStudio/feedback/details/797716/turning-off-auto-formatting-for-vs2013-c-only-seems-to-partial-disable-auto-formatting. Some possible workarounds:

    1. If you just peek into some projects which have different/weird style: if an unwanted auto-formatting happens, then you can perform one undo step, this should undo only the auto formatting part of the operation and not your contribution. Fortunately these two (or sometimes more auto formatting steps) are not grouped together into one command probably for this exact reason: you can go back and override it. It is annoying though if that happens all the time. You can configure the behavior to match your style, but you say you have project with different code styles.
    2. Tools/Import and Export Settings... - you can export the specific settings for a certain project and then import it later. This will save .vssettings XML format file. If it's about just a specific file type, than it can be just a few kilobytes long. Unfortunately this requires manual steps. The best would be if these settings could be overridden from the solution configuration file or even the project configuration file, could be part of them.
    3. Note, that this second point is problematic if you really work parallel in your projects with simultaneously open Visual Studios. In this case that settings will be saved finally what the last closed VS instance had I think.

    Having different auto formatting saved for solutions can be a feature request for next release (certainly not make it to VS 2013). What I usually come across is the tab/space indentation behavior differences, it's the most common difference in project styles. Indentation also can be configured individually for most file types, but as as in your case, projects can differ, and then it becomes annoying.

    0 讨论(0)
  • 2020-12-15 03:33

    I know this isn't exactly the answer you're looking for, but you can preserver that void f () formatting if you go to Tools > Options > Text Editor > C/C++ > Formatting > Spacing and under Spacing for function parantheses you check the option Insert space between function names and opening parentheses of argument list.

    0 讨论(0)
  • 2020-12-15 03:33

    Go to:

    Tools->Options->Text Editor->C/C++->Formatting->Spacing

    Then deselect or select the boxes that pertain to the code type you are writing.

    0 讨论(0)
  • 2020-12-15 03:44

    To turn off automatic brace completion, go to:

    Tools > Options > Text Editor > All Languages > General > Automatic brace completion

    ...then uncheck "Automatic brace completion".

    0 讨论(0)
  • 2020-12-15 03:45

    You can turn off automatic C / C++ /C# code formatting by going to the Options dialog from the Tools menu, selecting the Text EditorC / C++ / C#FormattingGeneral page, and unchecking all the boxes there. You'll still be able to manually format when all of the auto-formatting settings are turned off.

    0 讨论(0)
提交回复
热议问题