Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Fixing Indentation
Fixing Indentation [message #159133] Sun, 27 November 2005 19:02 Go to next message
Eclipse UserFriend
Originally posted by: void.void.com

Hi,

since I imported my source code into Eclipse (I used to code with
Emacs), the indentations are all messed up. The Java plugin for Eclipse
has a very nice feature (as does Emacs) where you can just hit one key
and it will automagically indent the selected region properly.

Can I do such a thing with CDT? I don't want to end up fixing
indentations for thousands of LOC myself.

Thanks in advance,
Matthias
Re: Fixing Indentation [message #159171 is a reply to message #159133] Mon, 28 November 2005 09:28 Go to previous messageGo to next message
Ali Burak Kulakli is currently offline Ali Burak KulakliFriend
Messages: 116
Registered: July 2009
Senior Member
You can use simple indent plugin from
http://softwitch.net/blog/index.php/simple-indent-code-forma tter-for-cdt/

Then CTRL+ALT+F.

It uses gnu indent. But it is possible to use astyle also. Simplest way it
just creating a batch file consisting of following lines.

astyle --style=ansi --break-blocks --pad=all %1
copy /Y %1 %3

you can even use both of them :)

indent %1 -bad -bap -bli0 -cbi0 -nprs -i4 -nut -sob -cli4 -cdb -sc -ss -npsl
astyle --style=ansi --break-blocks --pad=all %1
copy /Y %1 %3

Hope it helps,

"Matthias Kaeppler" <void@void.com> wrote in message
news:dmcvt1$knp$1@news.eclipse.org...
> Hi,
>
> since I imported my source code into Eclipse (I used to code with Emacs),
> the indentations are all messed up. The Java plugin for Eclipse has a very
> nice feature (as does Emacs) where you can just hit one key and it will
> automagically indent the selected region properly.
>
> Can I do such a thing with CDT? I don't want to end up fixing indentations
> for thousands of LOC myself.
>
> Thanks in advance,
> Matthias
Re: Fixing Indentation [message #159209 is a reply to message #159171] Mon, 28 November 2005 15:50 Go to previous message
Eclipse UserFriend
Originally posted by: void.void.com

Burak wrote:
> Hope it helps,

Very much so, thanks.

I think I'll write a script and use astyle and just replace all tabs
with spaces; that'll do the job. From there on I can do the formatting
myself :)

The CDT plugin doesn't support the Stroustrup C++ style which is my
favourite, and generally seems to be more focused on C than on C++ and
thus isn't very attractive to me.

It also acts pretty stupid in certain situations. For example, if I want
to fix indentation only for a certain block of code inside a function
body, the formatter will align it to column 0. ^^

Regards,
Matthias

PS: It's CTRL+/SHIFT/+F which calls the formatter by the way 8)
Previous Topic:Can't find gtk libraries
Next Topic:problem with CDT 3.0.1 installation with Eclipse 3.1.0 on SUN
Goto Forum:
  


Current Time: Sat Dec 20 22:26:14 GMT 2014

Powered by FUDForum. Page generated in 0.01580 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software