Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable all whitespace autoformatting in Visual Studio 2015?

People also ask

How do I turn off auto format in Visual Studio?

The solution was to go to 'Tools > Options > Text Editor > Basic > VB Specific' and turn 'Pretty Listing' OFF.

How do I enable whitespace in Visual Studio?

In Visual Studio for Windows, to display whitespace characters (tabs, spaces, etc) you simply press Ctrl + R, Ctrl + W.

How do I turn on auto indent in Visual Studio?

Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.


I realised I misunderstood the question in my original answer, so have added a partial answer disabling autoformatting for white space.
If you select ignore white space on all options where it is offered, it will not reformat the white space of those areas of code.

enter image description here

These screen shots are taken from VS2015 Enterprise.
I'm starting from the beginning to help anyone who lands here.

Go to Tools -> Options.

enter image description here

Scroll down to Text Editor. It's worth clicking through the all the general tabs. And the All languages tabs. There are some shared formatting settings that can be set, like line wraps.

enter image description here

Then go to the languages you wish to customise (I'm showing C#) and click on formatting. There you will find options, I have expanded the spacing one, as per the title of your question.

enter image description here

Then you can explore each of these tabs to customise your format for each language.

enter image description here

edit- since question has actually changed

To reduce the incidents of autoformatting, uncheck options like these:
enter image description here

The only way you can manage the autoformatting is to play with these settings. You can also use regex with find and replace to remove space from files, but do so carefully. Beyond these tips to customise your autoformatting, to reduce VS process of autoformatting and to manually autoformat, that's all I can think of.


There is also this: Under Edit -> Advanced -> Delete Horizontal White Space

enter image description here


The answer from Yvette Colomb is fine, but it does neither work on declarations inside functions, nor on enums (where in my opinion it is needed most).
Thus I had the idea to just add a comment between the variable and the operator, which simply breaks the obvious rule "set exactly one space character between variable (or enum name) and operator (=)", because there is no operator following the variable any longer! Not very nice, but also not too bad and IMHO it has definitely more advantages than disadvantages. :-)
enter image description here


Disable virtual space

Virtual space is a headache, please disable it int Tool>Options>Text Editor>C#>General. Life is better.