开发者

Eclipse C++: Format Source Files in Batch

开发者 https://www.devze.com 2023-02-19 04:41 出处:网络
Is it possible for me to use Eclipse to mass-reformat a bunch of C++ files (on the order of a few thousands), without actually having to open every single one in the IDE?

Is it possible for me to use Eclipse to mass-reformat a bunch of C++ files (on the order of a few thousands), without actually having to open every single one in the IDE?


Update:

A couple people have now posted solutions for the Java IDE, but this does not seem to work for the C++ IDE because there is no "Source" submenu in Proj开发者_JS百科ect Explorer. :(


This feature will be arriving in the next version of CDT (due in June 2011), CDT 8 in Eclipse 3.7. You can try it now using a milestone build of the platform + cdt: http://eclipse.org/downloads/packages/release/indigo/m6

The bug where this feature was added is here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=245747


I haven't tried it but how about using the Jindent command line?

Assuming you only want to do this once even if the solution is a bit Heath Robinson it should be fine as long as you get the right results. You can always use Perl to generate a shell script to call the beautifier multiple times with different options on different files/paths if needed. You could even try AutoHotKey for a truly ugly-but-perhaps-successful approach.


Are you looking for a C++ beautifier? This may have already been answered in Best C++ Code Formatter/Beautifier


Not specifically for Eclipse...

Our SD C++ Formatter reformats source files.

  • Two nice features for your problem: you can generate a project file telling it what files to reformat. It will do them all in batch.

  • It uses a full C++ parser to do so, builds an AST, and the prettyprints the result from the AST. It can't break your code. If you're going to reformat thousands of files, you might appreciate this.


In Eclipse 3.0 or newer, you can right click a folder and select Source > Format. That should format all source files in the folder using project specific settings.

Files have to be checked out (and thus be writable) for this to work.

0

精彩评论

暂无评论...
验证码 换一张
取 消