visual-studio 在 Visual Studio 中关闭自动格式设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/737222/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Turn off auto formatting in Visual Studio
提问by Maciej
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.
我是一个代码纯粹主义者,更喜欢我自己的代码格式风格,而不是 Visual Studio 的默认设置。我在工具/选项中关闭了自动格式化选项。在大多数情况下它有效。
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?
使用任何内置重构后,Visual Studio 会使用其默认设置破坏我的设置。我如何防止 VS 这样做?
回答by Tango91
I had this problem while writing VB in an aspxpage.
我在aspx页面中编写 VB 时遇到了这个问题。
The solution was to go to 'Tools > Options > Text Editor > Basic > VB Specific' and turn 'Pretty Listing' OFF.
解决方案是转到“工具>选项>文本编辑器>基本>VB特定”并关闭“漂亮列表”。
Note - in Visual Studio 2015 this can be found at:
注意 - 在 Visual Studio 2015 中,可以在以下位置找到:
Tools > Options > Text Editor > Basic > Advanced
工具 > 选项 > 文本编辑器 > 基本 > 高级
回答by RaRdEvA
回答by Contango
In my case, it was ReSharper.
就我而言,它是 ReSharper。
Test if ReSharper
测试是否 ReSharper
StackOverflow: How can I disable ReSharper in Visual Studio and enable it again?
StackOverflow:如何在 Visual Studio 中禁用 ReSharper 并再次启用它?
Prevent ReSharper from reformatting code
防止 ReSharper 重新格式化代码
StackOverflow: Is there a way to mark up code to tell ReSharper not to format it?
StackOverflow:有没有办法标记代码告诉 ReSharper 不要格式化它?
Update
更新
It was ReSharper in the end:
最后是 ReSharper:
回答by Efreeto
You might have had Power Toolinstalled.
您可能安装了Power Tool。
In this case you can turn it off from 'Tools > Options > Productivity Power Tools > PowerCommands > General'
在这种情况下,您可以从“工具”>“选项”>“生产力电动工具”>“PowerCommands”>“常规”将其关闭
回答by Tim Newton
As suggest by @TheMatrixRecoder took a bit of finding for me so maybe this will help someone else.

正如@TheMatrixRecoder 所建议的那样,我为我做了一些查找,所以也许这会对其他人有所帮助。

Unitick these options to prevent annoying automated formatting when you places a semicolon or hit return at the end of a line.
当您在行尾放置分号或按回车键时,Unitick 这些选项可防止烦人的自动格式化。
回答by TheMatrixRecoder
In VS2017 you can change it after selecting your coding language in the settings menu. There is an option called "new Lines" in the "Formatting"-submenu.
在 VS2017 中,您可以在设置菜单中选择编码语言后进行更改。在“格式”子菜单中有一个名为“新行”的选项。
回答by FrenkyB
回答by Chris Fox
The reformat on semicolon or closing brace cannot be turned off. I find it infuriating the Microsoft would have the temerity to tell anyone how to format code; the most illegible code I have ever seen was while working there.
无法关闭分号或右括号的重新格式化。我发现微软居然敢告诉任何人如何格式化代码,这让我很恼火;我见过的最难以辨认的代码是在那里工作时。
I want adjacent assignments to be vertically aligned; VS reformats them to one space on either side of the equal sign irrespective of the length of the variable on the left. This is intolerable. And turning it off on the editor options is ignored; given comments like the opener above I am certain this is deliberate.
我希望相邻的作业垂直对齐;VS 将它们重新格式化为等号两侧的一个空格,而不管左侧变量的长度如何。这是不能容忍的。并忽略在编辑器选项上关闭它;鉴于上面的开场白之类的评论,我确信这是故意的。
Consistency is only a virtue when it leads to desirable outcomes. This is not one.
一致性只有在带来理想结果时才是一种美德。这不是一个。
回答by Joey
I doubt that you can disable re-formatting after refactoring. Refactoring changes code and since it's only text I doubt what you'd want is that it just dumps unformatted text into your source. Wouldn't it be a little easier to just set the code style VS adheres to to the style you like and follow?
我怀疑您是否可以在重构后禁用重新格式化。重构更改代码,因为它只是文本,我怀疑您想要的是它只是将未格式化的文本转储到您的源中。将VS坚持的代码风格设置成你喜欢和遵循的风格,不是更容易一些吗?
回答by gozde berberoglu
Follow TOOLS->OPTIONS->Text Editor->CSS->Formatting Choose "Compact Rules" and uncheck "Hiearerchical indentation"
按照 TOOLS->OPTIONS->Text Editor->CSS->Formatting 选择“Compact Rules”并取消选中“Hiearerchical indentation”

