Formatting C ++ Code
I am using VS2005 and VS2008 now, with C #. Without any additional tools, I could hit ctrl k + d and the code would reformat nicely. Why doesn't C ++ do this? This is Visual Studio after all. Is there a way to enable it?
The second part of this question is related, for those who have used resharper with C #, is there a similar tool for C ++?
Edit: In 2017, this answer seems to be outdated. I recommend clang-format for "nothing", for "anyone".
Original answer: Ontopic: In VS2008 Express Format Selection select ALT + F8 and CTRL + K, CTRL + D is mapped to document format. This is probably the same in the professional versions of VS2008.
Less Ontopic: I try to avoid formatting source code for C ++ as I feel like they usually do more harm than good. What for? Codeformaters must "read" the code and understand what the various instructions in the code do. It's pretty easy, for example Java where the syntax is simple. C ++ is a very complex language. There are 10 ways to do anything. You can use macros, defines, typedefs and whatnot. Classes are usually defined / declared in two different files. This is also the reason why Intellisense seems to fail quite often - VS2008 fails to parse the code correctly. It is very difficult for an IDE to know what all statements are and how to format them. While it can work fine in most cases, you can be sure that it will give poor results from time to time.My guess is that Microsoft didn't spend too much time setting up the code formatting for C ++ as they understand that most C ++ programmers do it by hand. I rarely skip it, except when my colleague doesn't meet the company's standard.
source to share