Turn off auto formatting in Visual Studio

2019-01-04 01:00发布

I'm a code purist, preferring my own style of code formatting as opposed to Visual Studio's default settings. I've turned off auto-formatting options in Tools/options. In most cases it works.

After using any of the built-in refactorings, Visual Studio clobbers my settings with its default settings. How do I keep VS from doing that?

13条回答
神经病院院长
2楼-- · 2019-01-04 01:17

You might have had Power Tool installed.

In this case you can turn it off from 'Tools > Options > Productivity Power Tools > PowerCommands > General'

enter image description here

查看更多
一纸荒年 Trace。
3楼-- · 2019-01-04 01:18

You can tweak the settings of the code formatting. I always turn off all extra line breaks, and then it works fine for how I format the code.

If you tweak the settings as close as you can to your preference, that should leave you minimal work whenever you use refactoring.

查看更多
再贱就再见
4楼-- · 2019-01-04 01:21

I had this problem while writing VB in an aspx page.

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


Note - in Visual Studio 2015 this can be found at:

Tools > Options > Text Editor > Basic > Advanced

查看更多
走好不送
5楼-- · 2019-01-04 01:23

Follow TOOLS->OPTIONS->Text Editor->CSS->Formatting Choose "Compact Rules" and uncheck "Hiearerchical indentation"

查看更多
Evening l夕情丶
6楼-- · 2019-01-04 01:26

Disable pretty listing. It is the option that re-formats what you are doing. I had the same discomfort with it and after doing it, my code stays how i want and it doesn't go back to previous settings.

enter image description here

查看更多
别忘想泡老子
7楼-- · 2019-01-04 01:27

VS2015 settings that helped me prevent auto formatting:

(and Tools > Options > Text Editor > Basic > Advanced, just like Tango91 suggested)

enter image description here

查看更多
登录 后发表回答