Share via

How can I stop Visual Studio 2019 from automatically spacing out things?

Doug Matthews 26 Reputation points
2021-05-28T02:08:32.767+00:00

I'm irritated because I'm trying to write a ternary operator thus:

return (pname = player.GetName()) == null?"Undefined":pname;

...but what VS2019 keeps forcing on me is:

return (pname = player.GetName()) == null ? "Undefined" : pname;

I turned off all spacing options in Tools->Options->Text Editor->C#->Code Style->Formatting->Spacing and the last one which is a radio not a check I set to ignore yet it still spaces. I also tried setting the radio to remove, but to no avail. I made sure there is no .editorconfig that could be overriding as well.

So how can I get it to leave my code alone?? Thanks!

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.

0 comments No comments

Answer accepted by question author

Anna Xiu-MSFT 31,201 Reputation points Microsoft External Staff
2021-05-28T07:08:53.093+00:00

Hi @Doug Matthews ,

Welcome to Microsoft Q&A!

According to your description, you can unselect the following option to disabling automatically code format: Tools > Options > Text Editor > C# > Code Style > Formatting.
100360-image.png

Sincerely,
Anna

  • If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.