Yesterday I spent quite a good few hours trying to figure out how to achieve single line if statements with document formatting (ctrl+k ctrl+d) and I did not succeed.
I had Jetbrains Resharper C++ also running next to VisualGDB – by the way they work together perfectly – which might be an important detail. Normally setting up something like this takes just a little googling and some gut driven intuition. I think this is not the case here. Multiple sections for C/C++ and Cland tidy is also mixed into the picture.
One test I’ve done one test though: i used a minimal main.c with a single line if statement in a function.
1 – all extensions on – VisualGDB off: formatting is good. It does what I expected. (well, I like single line ifs)
2 – all extensions off – VisualGDB on: formatting breaks the single line if statement in two lines.
So this made me thinking that the formatting issue has something to do with VisualGDB. Please point me into the right direction! I’m sure it’s somewhere in front of me. 🙂
VisualGDB would normally use the clang-format engine to format the source code. Clang-format uses its own configuration files that are not 100% in sync with the regular Visual Studio formatting options (although VisualGDB does synchronize the main options).
That said, VisualGDB comes with a graphical editor for the clang-format configuration files, so you can easily tweak the code formatting behavior by clicking the button shown below: