简体   繁体   中英

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:

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:

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? 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".

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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