【问题标题】:Visual Studio export .editorconfig has no content for c++Visual Studio 导出 .editorconfig 没有 c++ 的内容
【发布时间】:2021-03-17 00:07:44
【问题描述】:

我尝试将我的 C++ 格式设置导出到 .editorconfig,但使用我尝试的 2 种方法,配置几乎完全空白,除了简短的注释标题和语言文件格式选择器。

使用这里描述的方法:

https://stackoverflow.com/a/51437947/2033725

生成一个只包含以下内容的编辑器配置:

# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\ProjectName codebase based on best match to current usage at 12/4/2020
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]

我的项目是c++通过cmake生成的。

我还尝试导航到工具 > 选项 > 文本编辑器 > C/C++ > CodeStyle 并使用设置中的生成 .editorconfig 文件。这给了我以下信息:

# Visual Studio generated .editorconfig file with C++ settings.

[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
vc_generate_documentation_comments = doxygen_slash_star

如果我使用项目 -> 添加新项目并选择 .editorconfig(默认),我会得到:

# All files
[*]
indent_style = space

# Xml files
[*.xml]
indent_size = 4

我对我的 c++ 设置进行了一些更改,这些更改在 .editorconfig 领域中是完全可以理解的,甚至还有它的键:

https://docs.microsoft.com/en-us/visualstudio/ide/cpp-editorconfig-properties?view=vs-2019

cpp_indent_namespace_contents cpp_indent_case_labels cpp_indent_case_contents 等等

我的印象是,当不存在现有的 .editorconfig 时,Visual Studio 用于我的格式设置的设置将被导出。这不正确吗?

这是使用 Visual Studio Intellicode 2.2.123.30197 的 Visual Studio 版本 16.7.7

【问题讨论】:

    标签: c++ visual-studio-2019 editorconfig


    【解决方案1】:

    您可以选择将.editorconfig保存在Tools->Text Editor->C/C++->Code Style->General->Generate .editorconfig file from settings中的文件夹路径。

    然后你需要编译这个项目。然后editorconfig就会出现在刚才设置的保存路径中。

    【讨论】:

    • 非常感谢。编译项目并不是我在精神上与生成内容相关联的事情,并且据我所知,文档并未将此列为要求。
    【解决方案2】:

    FWIW:我必须在 Visual Studio 工作之前更新它。我显然有一段时间没有这样做了,在https://developercommunity.visualstudio.com/t/c-editorconfig-formatting-conventions-not-working/1186683 他们为此功能参考了 16.8.0 版本。

    看起来最近发生了很多更新。

    https://docs.microsoft.com/en-us/visualstudio/releases/2019/history

    因此,对于看到此内容的其他人,请检查您的版本,检查更新。它得到了我。 ;)

    【讨论】:

      猜你喜欢
      • 2018-12-23
      • 2018-05-01
      • 2017-08-01
      • 1970-01-01
      • 2017-09-30
      • 2023-01-02
      • 1970-01-01
      • 2020-02-25
      • 2016-07-13
      相关资源
      最近更新 更多