Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any tool to standardize format of C++ code? [closed]

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

like image 940
Billy ONeal Avatar asked Mar 17 '10 16:03

Billy ONeal


People also ask

How do I tidy up code in Visual Studio?

Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup.

How do I format C code?

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.

Does prettier work with C++?

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.

How do you run a clang-format?

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.


1 Answers

GNU Indent should get you most of the way there

like image 92
Ana Betts Avatar answered Sep 19 '22 04:09

Ana Betts