Visual Studio export .editorconfig 没有用于 c++ 的内容

Visual Studio export .editorconfig has no content for c++

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

使用此处描述的方法:

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

# 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]

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

我还尝试导航到工具 > 选项 > 文本编辑器 > 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

如果我使用项目 -> 添加新项目和 select .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 版本 16.7.7 使用 Visual Studio Intellicode 2.2.123.30197

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

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

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

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