问题
I've written a lot of functions without paying attention to their order and it has gotten kind of messy.
I want to make my code more readable by having the order of functions in my .cpp files match the order in the .h files. Is there a way to do this automatically in Visual Studio 2015 or do I have to do it manually?
What other options are there to automatically format my code to make it more readable in Visual Studio 2015?
回答1:
There isn't a built-in feature to do this. However you can collapse all of your implementations using Ctrl+M then Ctrl+O to make it easier to manipulate them. Ctrl+M then Ctrl+P disabled outlining after your done.
For the second part of your question, press Ctrl+K then Ctrl+F to automatically format any highlighted code. Ctrl+K then Ctrl+D automatically formats the entire document. The formatting rules are controlled in Tools->Options...->Text Editor->C/C++.
Other useful shortcuts can be found in Edit->Advanced or Edit->Outlining.
来源:https://stackoverflow.com/questions/41470590/order-functions-in-cpp-files-to-match-order-in-h-files-in-visual-studio-2015