You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Visual Studio 2022 Community缩进异常问题求助

Visual Studio 2022 Community 缩进异常问题

几天前Visual Studio 2022社区版的缩进功能正常,按回车后光标会在括号后正确缩进,括号也能对齐。但现在按回车后缩进出现异常,即使设置IntelliSense换行后不插入制表符,问题仍未解决。

异常示例

无论设置哪种C#缩进模式,都会出现某处多余缩进的问题:

1. Smart缩进模式

将C#的Indenting设为Smart,tab size和indent size均设为4,输入类Foo的代码后结果如下:

public class Foo
    {
        int bar;
    }

大括号前出现多余缩进,不符合预期。

2. Block缩进模式

将Indenting设为Block,tab size和indent size仍为4,输入相同代码时结果如下:

public class Foo 
{
        int bar;
    }

此时int bar;前出现8个空格的多余缩进。

3. 关闭自动缩进(None模式)

关闭自动缩进后手动输入,仍会出现异常:
输入类结构后:

public class Foo
{

    }

输入int bar;后再次出现多余缩进:

public class Foo
{
        int bar;
    }

设置冲突问题

All Languages和C#的tab size、indent size均设为4,针对C#设置Indenting时正常,但设置All Languages的Indenting时会提示:

个别文本格式的缩进设置相互冲突。
导致All Languages的Indenting单选按钮无法选中。

期望效果

希望恢复之前的状态:自动识别块级缩进为4个空格,无多余缩进且无需手动调整。

内容的提问来源于stack exchange,提问作者mishar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 11:42:34