1

This question (How to disable all whitespace autoformatting in Visual Studio 2015?) shows different formatting options when writing in a language - for example C#. But it doesn't cover the problem of everytime I save a file all whitespace is stripped.

This is INCREDIBLY irritating since I can't go into a file an edit just a line of it and commit. I get merge conflicts everytime there is an extra space anywhere in the file.

I don't want VS 2015 to change white space when I save a file. I do want VS to format my code for me...

Community
  • 1
  • 1
Zach Smith
  • 8,458
  • 13
  • 59
  • 133
  • Are you whitespacing by space literal or by TAB? You need to set TAB to "Insert Spaces" otherwise, or they will be purged on the format pass – schulmaster Apr 03 '17 at 16:14
  • Thanks. I found that setting, but it doesn't stop VS stripping unneeded white space on save. For example there is a line with 11 spaces at the end of it. When I save, there are 0 spaces at the end of it. This then gets seen as a change in git, and if someone edited that line in addition to me there is a merge conflict. – Zach Smith Apr 03 '17 at 16:27
  • I am using VS2015. The other dev in this case is using VS2013 – Zach Smith Apr 03 '17 at 16:28
  • I don't know if this would be comprehensive, but two format settings that will preserve a subset of intentional space padding are: In Tools->Options->TextEditor->C#->Formatting->Spacing: Ignore Spaces in Declaration Statements- check this; Ignore spaces around binary operators- click this radio button(towards bottom); – schulmaster Apr 03 '17 at 16:43
  • @schulmaster that didn't work. the only solution that seemed to work was upgrading to 2017 - also I should mention that I was using bootcamp on a mac previously and I'm not now. – Zach Smith Apr 11 '17 at 14:45

1 Answers1

-2

The solution is to upgrade to 2017. The default configuration does what I want. I was not able to get this to work with 2015.

Also I should mention that I was previously running Windows 10 on a mac via Bootcamp and now I'm not. It really shouldn't have mattered but who knows...

Zach Smith
  • 8,458
  • 13
  • 59
  • 133