none
How to disable all auto-formatting / auto-indentation? RRS feed

  • Question

  • I'm not sure if this question belongs here but I couldn't find a forum best suited to this.

     

    All the way back to Developer Studio 6.0 and now in .NET I've had problems with the editor automatically reformatting my code.  I've tried everything imaginable to prevent this -- disabled auto indentation, smart formatting, etc.  The editor continues to indent blocks without my authorization, and to remove indentations.  Is there any way to prevent the editor from attempting to do ANY auto formatting of my code?  It is beyond frustruting that this problem has persisted and continues to plague me on a daily basis.  LET ME WORRY ABOUT HOW MY CODE IS FORMATTED!!

    Friday, September 7, 2007 3:17 PM

All replies

  • Shane, I have the same issue. When I click on controls in my designer the source code above (split screen mode) goes crazy indenting and adding huge white spaces for no reason. If I find a way to disable this I will be sure to post it..

    Monday, September 10, 2007 6:06 PM
  • Shane, have you tried changing the settings under the "Text Editor" category in the Tools->Options dialog?  To start with, change All Languages->Tabs->Identing to "None".  You may also need to change settings under specific languages depending on which ones you use.

     

    -Josh

     

    Wednesday, September 12, 2007 7:14 PM
  • Same problem for me, and it's extremely frustrating. Another thing I've noticed is if I copy and paste code, it formats the pasted code. So it I copy and paste:

    <li><a href="#"></a></li>

    I get:

    <li>

      <a href="#"></a>

    </li>

    I've tried to disable all autoformatting with no luck. I've given up on VS 2010 and gone back to 2008.

    Tuesday, October 5, 2010 9:39 PM
  • Josh led the way pointing to the Text Editor but there is a little more to do to turn off all auto formatting in Visual Studio when working with html.

    In Visual Studio (tested with VS 2010) in order to turn off the html formatting :

    Tools -->  Options --> Text Editor --> HTML --> Formatting --> Tag Specific Options --> Default Settings

    Under Default Settings there are four different selections each one is its own tab page and each has its own checkbox controlling whether to indent so ...

    Default Settings --> Client tag does not support contents --> Uncheck Indent Contents checkbox

    Default Settings --> Client tag supports contents --> Uncheck Indent Contents checkbox

    Default Settings --> Server tag does not support contents --> Uncheck Indent Contents checkbox

    Default Settings --> Server tag supports contents --> Uncheck Indent Contents checkbox

    After unchecking all four of those checkboxes ...

    Ok --> Ok

    Now you should be squared away and your file left in the state you saved it in.

    ... a K.I.D. was here ...

    Sunday, September 22, 2013 5:32 AM
  • Same problem for me, and it's extremely frustrating. Another thing I've noticed is if I copy and paste code, it formats the pasted code. So it I copy and paste:

    <li><a href="#"></a></li>

    I get:

    <li>

      <a href="#"></a>

    </li>

    I've tried to disable all autoformatting with no luck. I've given up on VS 2010 and gone back to 2008.


    So you like don't formatting bad/ugly formatted code to something clear/clean/good formatted Code ... sorry just kidding ... :D
    Wednesday, February 19, 2014 2:03 PM
  • Nope. Microsoft continues to know better than I do how I want my code to look.
    Wednesday, June 4, 2014 2:56 PM
  • This behavior of VS surely is very frustrating.

    Who has given authority to Visual studio team to decide on behalf of end user?

    If we don't want VS to auto format our file, then we should have complete control over it.

    Monday, June 27, 2016 1:55 PM
  • I found this thread while searching for a way to stop Visual Studio 2015 from changing the indentations of my code when I paste something.  I dug through the options and FINALLY found the solution.

    Go to Tools > Options > Text Editor > (the language you're working with) > Formatting > General.

    With C# you will see three checkboxes:

    - Automatically format statement on ;

    - Automatically format block on }

    - Automatically format on paste

    Uncheck these and you're good.  FINALLY!!  This should hopefully also work in other versions besides 2015.


    • Edited by yyr1 Saturday, September 16, 2017 7:50 PM
    Saturday, September 16, 2017 7:49 PM
  • Thank you very much for this post.  Incredibly, this same set of settings (under C#!) actually seem to govern Master pages under VB!  I was pulling my hair out trying to get the IDE to quit reformatting my code every time I pressed Enter.  I like to have the VB source follow the same indentation pattern as the HTML, which the IDE fights one tooth and nail to prevent - until I made your change.

    Affected product:  ** Visual Studio 2019 **

    • Edited by Zaxxonal Tuesday, October 8, 2019 12:33 AM
    Tuesday, October 8, 2019 12:32 AM
  • No, useless.

    I'm in C++ and have a similar set of checkboxes. Everything unchecked. Everything else I can see that auto-corrects unchecked.

    Create my constructor, go to the next line and type a tab because I want one. I then type the colon to start my initializer list and VS moves the colon to the start of the line.

    I DIDN'T WANT IT THERE, I TYPED IT WHERE I DID BECAUSE THAT IS WHERE I WANT IT TO GO.

    STOP AUTO-CORRECTING ME.

    The ONLY time I want it to move anything is a closing brace to match the opening one above it. And after opening a brace I want it to put me one tab in. But if I don't type there but choose to type somewhere else DO NOT MOVE WHAT I TYPED.

    Monday, December 9, 2019 11:32 AM