Title: VS 19 - When I initialize a variable it suddenly 'reformats' it, how do I turn it off?
Tags: c++;visual-studio;visual-studio-2019
Question: When I type something like:
int some_int{3};
VS Immediately changes it to:
int some_int{ 3 };
I don't like how that looks and honestly I just want for it to stay the way I've written it in most cases, although I do appreciate the help when it comes to style guides that are best to follow (since I'm still a beginner) in some cases like the one above it can get really annoying. Could someone please tell me how to turn it off?
Comment: Personally I'd roll with it until you have a few months experience under your belt. (Although that said I've turned it off somehow ;-) )

Comment: On the two large Visual Studio based projects I've worked on, the path of least resistance for the team was just to use the default formatting that Visual Studio came with out-of-the-box.  That being said, you can either disable the formatting, or fine-tune the formatting so that it is closer to your preferred format.  (For my own hobby projects, I turn it off altogether.)

Comment: Go to Options, in the Editor section there should be a way to turn it off.

Here is the accepted answer: To change the formatting in Visual Studio, goto Tools → Options... → Text Editor → C/C++ → Formatting. There, you will see a variety of formatting options.
For your issue, you specifically want to un-check the box at ... → Formatting → Spacing → Spacing for braces → Insert space within braces of uniform initialization and initializer lists.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:10/13/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c++><visual-studio><visual-studio-2019>', 'Title': "VS 19 - When I initialize a variable it suddenly 'reformats' it, how do I turn it off?", 'ViewCount': 95, 'id': 64339498, 'user_AboutMe': None, 'user_AccountId': 19563363.0, 'user_DisplayName': 'Krapnix', 'user_Reputation': 257.0, 'user_Views': 33.0, 'user_id': 14316120.0}}