I'm looking for a tool that works on Windows to reformat some C++ code in my codebase. Essentially, I've got some code I wrote a while ago that I'd like to use, but it doesn't match the style I'm using in a more recent project.
What's the best way to reformat C++ code in a standard manner?
Billy3
Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup.
The C/C++ extension for Visual Studio Code supports source code formatting using clang-format which is included with the extension. You can format an entire file with Format Document (Ctrl+Shift+I) or just the current selection with Format Selection (Ctrl+K Ctrl+F) in right-click context menu.
Prettier wasn't intended to format C++ code. You should install the C/C++ for Visual Studio Code extension developed by Microsoft, it supports code formatting. Details can be found in the Visual Studio Code documentation.
You can install clang-format and git-clang-format via npm install -g clang-format . To automatically format a file according to Electron C++ code style, run clang-format -i path/to/electron/file.cc . It should work on macOS/Linux/Windows.
GNU Indent should get you most of the way there
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With