简体   繁体   English

使用 Visual Studio 2022 格式化 C/C++ 代码

[英]Formatting C/C++ code with Visual Studio 2022

I've been using Visual Studio 2022 for the last few months, and I want to have my C and C++ code formatted with the following style:过去几个月我一直在使用 Visual Studio 2022,我希望将我的 C 和 C++ 代码格式化为以下样式:

if (someCondition) {

    // Do something

} else if (someOtherCodition) {

   // Do something else

} else {

   // Otherwise

}

However, after entering the code with the above format, the IDE displays the code with the following format on reload:但是,输入上述格式的代码后,IDE 在重新加载时显示以下格式的代码:

if (someCondition) {

    // Do something

}
else if (someOtherCodition) {

   // Do something else

}
else {

   // Otherwise

}

which looks very untidy.这看起来很不整洁。 How do I configure the IDE to keep the format that I enter?如何配置 IDE 以保持我输入的格式? This is not really a programming question, but would appreciate some guidance.这不是一个真正的编程问题,但希望得到一些指导。 There must be an option that can be changed, but I can't find it.必须有一个可以更改的选项,但我找不到。

Reset/uncheck the option "Place 'else' on new line".重置/取消选中“将'else'放在新行上”选项。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM