I suggest you ...

Put an option to disable indentation after pasting code

Vertically line up arguments of a function call. Then copy the block of code. Paste it somewhere else. The allignment which you carefully made is all gone. You have to do the same custom formatting every single place you paste your code.

Unfortunately, there is no way of preventing this in Visual Studio 2015. I checked for a solution on the internet. Most people are complaining about the same problem and there is no cure.

Please provide an option for disabling this behavior.

3,172 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    HanHan shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    14 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • tsahitsahi commented  ·   ·  Flag as inappropriate

        If your method takes so many parameters they need to be listed vertically, you should consider refactoring it to smaller methods, or use a DTO.

      • AnonymousAnonymous commented  ·   ·  Flag as inappropriate

        If all the auto-formatting in turned off in settings, my code should stay exactly where I type it...period.
        Forget about how I SHOULD be formatting, it boils down to my choices. It I tell the editor "don't do it", I expect it work. In previous versions it worked fine and does not auto-format. Bottom line is, it's broken in VS 2015.

      • Dinesh ygvDinesh ygv commented  ·   ·  Flag as inappropriate

        Even after unchecking Tools\Options\Text Editor\C#\Formatting\Automatically format pasted code, it still formats after pasting. This could be a bug.

      • cbhackingcbhacking commented  ·   ·  Flag as inappropriate

        What Kevin said... this option already exists, has existed for years, did you even check the Options panel's Formatting sections? I mean, it's a big thing to check, but it's also the obvious place for this.

      • William MoussiauxWilliam Moussiaux commented  ·   ·  Flag as inappropriate

        It's 'my' code.

        I'll format it however I choose, not how someone else thinks it should be.
        The editor should not touch my code unless I say it can.
        There's no reason I should have to Ctrl-Z or any other function to undo what I didn't want done to start with.

      • ChiramisuChiramisu commented  ·   ·  Flag as inappropriate

        I'm sure you have your reasons, but I'm not sure why you'd want to do this. One should use proper formatting and indentation to make the code more standardized and easy to read by other developers who are also used to seeing the code displayed in that way. ;)

      • SlanSlan commented  ·   ·  Flag as inappropriate

        Yes, Ctrl+Z fixes it. But why do I have to do it EVERY time?

      • tsahitsahi commented  ·   ·  Flag as inappropriate

        I would be worried that you are copying and pasting code. Keep your code DRY.

      • JonathanJonathan commented  ·   ·  Flag as inappropriate

        Whenever this happens to me I do Ctrl+Z which undoes the formatting without undoing the pasting.

      • AnonymousAnonymous commented  ·   ·  Flag as inappropriate

        Does control-z help? Sometimes when I paste, I can press control-z to undo the new formatting, and pressing control-z a second time will undo the paste.

      Feedback and Knowledge Base