[英]Visual Studio 2022 turn off auto indenting
Text Editor - C# - Code Style - Formatting Indentation文本编辑器 - C# - 代码样式 - 格式化缩进
check / uncheck boxes to see how your code will look and save when happy选中/取消选中复选框以查看您的代码在高兴时的外观和保存方式
After consolidating code blocks to one block on the razor page... this seems to have corrected the issue.在 razor 页面上将代码块合并为一个块之后......这似乎已经纠正了这个问题。 the indenting I believe may have been caused by some bug where the indenting fails due to attempting to address other formatted code.
我认为缩进可能是由于尝试处理其他格式化代码而导致缩进失败的一些错误引起的。 this is not really a solid answer but i did find that moving things around prevented this from occuring and this was nothing to do with any indenting settings within the tools text editor options.
这不是一个真正可靠的答案,但我确实发现移动东西可以防止这种情况发生,这与工具文本编辑器选项中的任何缩进设置无关。
I'm not sure if you ever found the correct answer to your question, but I was having the same problem, and reading the other two answers led me to figuring it out.我不确定你是否找到了问题的正确答案,但我遇到了同样的问题,阅读其他两个答案让我弄清楚了。 The problem is with the adaptive formatting option being turned on.
问题在于启用了自适应格式选项。 To turn it off, go to
要关闭它,go 到
Tools -> Options -> Text Editor -> Advanced工具 -> 选项 -> 文本编辑器 -> 高级
Uncheck 'Use adaptive formatting'取消选中“使用自适应格式”
Save, and restart Visual Studio保存并重新启动 Visual Studio
This should do the trick for you.这应该为您解决问题。
There is another option under Tools - Options工具 - 选项下还有另一个选项
Text Editor - All Languages - Tabs.文本编辑器 - 所有语言 - 选项卡。
Try to specify Tab size and indent size尝试指定制表符大小和缩进大小
I believe it is a bug or a new "feature".我相信这是一个错误或一个新的“功能”。 Mine works in VS2019, but worked better in previous versions.
我的在 VS2019 中工作,但在以前的版本中工作得更好。 Each new version becomes harder to maintain the indentions that I prefer.
每个新版本都变得更难维护我喜欢的缩进。 It is not language dependent either as I also work in VB and it happens there as well.
它也不依赖于语言,因为我也在 VB 中工作,它也发生在那里。
For example, in both languages, my personal preference is to add a comment and then indent the code following the comment.例如,在这两种语言中,我个人的偏好是添加注释,然后在注释后面缩进代码。 I have been doing code this way for two decades...my eye flows down the page seeing the flow and code much easier and faster.
二十年来,我一直在以这种方式编写代码……我的眼睛顺着页面向下流动,看到流程和代码变得更加轻松快捷。
BUT...in VS2022, every time I indent a code block, the moment I hit enter, my indentions all move to the left, aligned with the comment....so aggravating.但是......在VS2022中,每次我缩进一个代码块时,当我按下回车键时,我的缩进都向左移动,与注释对齐......所以加重了。 Then I have to ctrl-z to make it go back.
然后我必须按 ctrl-z 使它 go 回来。 Of course, it goes back only until the next line.
当然,它只会返回到下一行。 And often it will reformat the entire function and align everything, all code, all comments, etc.
通常它会重新格式化整个 function 并对齐所有内容、所有代码、所有注释等。
All I desire is for it to leave the indentations where I placed them.我只希望它留下我放置它们的凹痕。 So far in VS2022, I have not found how to do this.
到目前为止,在 VS2022 中,我还没有找到如何做到这一点。 Hoping someone finds an answer to this.
希望有人能找到这个问题的答案。 I will be watchign and thanks in advance!
我会注意并提前感谢!
Welcome to the new and improved (super buggy) VS 2022 cshtml page editing experience.欢迎来到新的和改进的(超级错误)VS 2022 cshtml 页面编辑体验。 Click
Help -> Send feedback -> Report a problem
and tell 'em about it.单击
Help -> Send feedback -> Report a problem
并告诉他们。
In visual studio 2022 community:在 visual studio 2022 社区中:
effects are reflected without even restarting visual studio甚至无需重新启动 visual studio 即可反映效果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.