How to prevent Visual Studio Editor from reformatting my line?

Nicholas Piazza 541 Reputation points
2024-02-07T22:56:05.7933333+00:00

When I enter lines in Visual Studio I like to have certain items line up. For example,

        btnAccumulate.Hide   ();
        labelResultList.Hide ();
        lbResultList.Hide    ();
        labelResult.Show     ();
        tbResult.Show        ();

etc., in which I line up the parameter lists below each other. However, if I perform some other action, such as add an event handler from the properties box, Visual Studio will reformat those lines above so there is only one space between the method name and the parameter list. I have looked through the formatting options, but I don't see (or understand) which option will retain my formatting. Can you point me in the right direction? Thanks

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,449 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 30,966 Reputation points Microsoft External Staff
    2024-02-08T03:17:46.6166667+00:00

    Hi @Nicholas Piazza

    Welcome to Microsoft Q&A! 

    You can try to disable the setting “Automatically format statement on;” by going to Tools > Options > Text Editor > C# > Code Style > Formatting > General.

    If it doesn’t work, you can uncheck all settings in the following screenshot and try again:

    User's image

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    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.

    1 person found this answer helpful.

Your answer

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