【问题标题】:Format (4 spaces) all code files in Visual Studio?格式化(4 个空格)Visual Studio 中的所有代码文件?
【发布时间】:2021-03-05 23:12:44
【问题描述】:

我正在处理一个旧分支 feature/old-request,该分支没有通知 Visual Studio 使用 4 个空格的 .editorconfig 文件(公司同意的格式)。

所以在我的旧分支上,Visual Studio 使用的是我自己的个人设置(2 个空格)。现在我正在尝试合并分支(developfeature/old-request),我得到了很多更改的文件,唯一的更改是间距。

我现在中止了合并,然后从develop 分支中取出相同的.editorconfig 文件并将其放在我的feature/old-request 分支上。

我不喜欢打开 100 个文件并按下 Ctrl + K Ctrol + D

有没有办法告诉 Visual Studio 格式化所有代码文件?

【问题讨论】:

    标签: git visual-studio code-formatting


    【解决方案1】:

    dotnet CLI 中有很好的工具:dotnet-format

    也可以直接从命令行安装:

    dotnet tool install -g dotnet-format
    

    现在,当您的目录具有这样的解决方案设置时:

    path to solution catalog
    -- ConsoleApp
    -- .editorconfig
    -- ConsoleApp.sln
    

    (这只是示例解决方案)。

    现在,在解决方案目录中运行命令dotnet-foramt,它会自动将.editorconfig 中的设置应用到您的解决方案。

    【讨论】:

      猜你喜欢
      • 2023-03-17
      • 1970-01-01
      • 2019-04-14
      • 2018-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      相关资源
      最近更新 更多