if (condition)
{
}
else {
}
I like the curly braces to be on the same line so that I can see more code in less lines:
if (condition) {
} else {
}
To define this format in Visual Studio 2022, go to Tools - Options - Text Editor - C/C++ - Code Style - Formatting - New Lines and uncheck the boxes at the bottom:
After this change, you can update the format of an existing file with Edit - Advanced - Format Document.