views:

544

answers:

6

I am trying to use "indent" program to indent C++ programs. But it does not seem to work fine. It is messing up the indentation much more.

It is a Class file. Can you please suggest the right options for it or another program that works?

Thanks

+8  A: 

Try Artistic Style:

Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C# and Java programming languages.

Andrew Hare
+6  A: 

in visual studio, ctrl+a, ctrl+k, ctrl+f will auto-indent the entire file you're working in.

Rantaak
+3  A: 

Many editors like Vim and Emacs have a feature that reindents code according to its built-in indentation standard.

In Vim, you can type = with any motion. (Like =% at any block delimiter or <shift-V> to select a region and then = to reformat.)

greyfade
emacs: Escape-x indent-region. (Select region first.)
Mr.Ree
and use `M-< C-space M->` to select the entirety of the current buffer...
dmckee
+2  A: 

bcpp, available in any linux distro (and probably for mingw/cygwin, but I have not checked it) is a C++ indenter and beautifier. You can parametrize how it works with the code.

David Rodríguez - dribeas
+1  A: 

Another short key in Visual Studio 2008:

Ctrl+A, Alt+F8

Vadakkumpadath