Home > Enterprise >  Visual Studio randomly adds a lot of spaces to my code
Visual Studio randomly adds a lot of spaces to my code

Time:10-11

I have a page open writing some code and then out of nowhere after some random time my page reformats and my spaces get turned into tabs. I have to close the file and re-open in order for it to get fixed. Please have a look at the screenshot below.

I am using c# and Visual Studio 2019. I Recently updated to the latest version of visual studio and this is when this started happening. I am now on version 16.11.4. I also installed .NET 5 at the same time so not sure if something there could be messing with visual studio.

enter image description here

Edit: I Think I figured out why the spaces are added. If you look at this new screenshot you will see that it injected the gray lettering where spaces were. I tried clicking around in the empty spaces few times and those gray letters showed up. I Guess the page is having trouble loading all these in until I click on them?

Anyone has any idea why?

enter image description here

CodePudding user response:

I had the same problem when I had Resharper installed, and I upgraded to the latest version of Visual Studio.

Are you using Resharper? If yes, disable it or downgrade Visual Studio to a version compatible with your version of Resharper.

CodePudding user response:

I believe this is caused by your word wrapping preferences and then resizing your window. Go to File - Preferences - Settings and then search for "wrap" and play around with the settings or turn it off.

  • Related