none
Auto-format vs Re-format vs UN-format - is it possible to make VS leave my code the way I wrote it?

    Question

  • Can anyone help me understand how to get VS2019 (16.0.4) to basically just leave my code alone?

    I have unchecked the option (in the c# text editor) to "automatically format code on paste" because I don't want it changing my code - AT ALL.  But then if I copy/paste code that has indented lines, using tabs (which VS converts to 4 spaces as I want), VS UN-formats it COMPLETELY - all justified left, my tabs/spaces removed.  And if I leave the option checked then it RE-formats the code.  I have tried to turn OFF every option I could find related to auto-formatting.  I just want my code the way I write it, period.  Is it even possible?  

    (This has been an issue since long before 2019, and I've read many posts that span many years about the issue.)

    Thursday, May 16, 2019 10:30 PM

All replies

  • Maybe you should not change the options that are sometimes useful, but, when you paste a text and do not need the reformatting, perform Undo (press <Ctrl+Z>).

    Friday, May 17, 2019 5:12 AM
  • Along with "automatically format code on paste", did you uncheck "Apply all c# formatting rules". Try by un-checking both options.

    Regards, http://www.shwetalodha.blogspot.in/

    Friday, May 17, 2019 6:32 AM
  • Thank you for the reply. That is what I am doing right now, but on top of several other inconveniences it is souring my opinion of continuing to use Visual Studio.  In recent years MS continues to focus their efforts on advanced new features that appeal in marketing ads and to huge companies, and yet let real-world problems go unresolved.  
    Friday, May 17, 2019 8:23 AM
  • I have no such option.  Can you post a screenshot?

    Friday, May 17, 2019 8:24 AM

  • Due to org guidelines, this option is disabled for me. But you can verify this in yours.

    Regards, http://www.shwetalodha.blogspot.in/


    Friday, May 17, 2019 8:51 AM
  • Well this is disappointing.

    I cannot post my screen image - however I can say that I only have the top frame of your screenshot, and don't have the "Format Document" section whatsoever.


    Could this be due to a difference in editions?  I use the Community edition currently.  I would hate to think that's the cause of this as it doesn't seem like those options would create marketing issues.  What edition are you using?

    I don't know what MS has to do in order to "verify my account" but it's sad that I cannot even post a small jpg screenshot image.  Perhaps their email is sitting in my spam folder LOL

    Friday, May 17, 2019 8:38 PM
  • It appears that they have either removed those options in 2019, or hidden them beyond my ability to find.  I am assuming that you are not using 2019 - correct?
    Friday, May 17, 2019 8:56 PM
  • I'm using VS 2017 enterprise edition. And yes, you are right, it is not completely migrated to VS 2019. But you can get some of the settings under different section. See thisattached clip, which I got it from developer community

    Regards, http://www.shwetalodha.blogspot.in/


    Saturday, May 18, 2019 12:14 AM
  • First, THANK YOU for taking the time to reply and share your observations and insight!  I have been posting on various sites and have had a shocking lack of help.  I don't usually post to forums, this is probably my third time in as many years.  I have read a LOT of posts from other developers about similar issues, but next to zero in the way of help (and zero from any MS folks about it).

    I don't have that green checkmark icon either (which I've read seems to be something called a "health" icon?).  Again, I am only using the Community edition, because according to the MS comparison chart that should not impact the code editing features - and I'm not yet sure I want to stay with Enterprise, or even Pro honestly, if my eval of 2019 with Community continues this way.

    Saturday, May 18, 2019 1:02 AM
  • Hi HannibalAnthrope,

    Like the Shweta's reply, you could do the similar operation at the bottom of community editor like this image:

    Hope it can help you.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, May 24, 2019 11:03 AM