Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » [3.0M9] Formatter not obeying tabs vs. spaces settings?
[3.0M9] Formatter not obeying tabs vs. spaces settings? [message #165873] Fri, 25 June 2004 14:02 Go to next message
Eclipse UserFriend
Originally posted by: eclipse.rizzoweb.com

I am working with an existing code base that, unfortunately, uses an
inconsistent mixture of tabs and spaces for indentation.
So as I touch various files, I am trying to re-format them to use tabs
consistently. Problem is, the formatter is not doing what I expect when
I re-format existing code.
Here's an example method that is formatted weirdly:

<sp><sp><sp><sp>public void foo()
<sp><sp><sp><sp>{
<tab>doSomething();
<tab>doSomethingElse();
<tab>}

Which looks like this:
public void foo()
{
soSomething();
doSomethingElse();
}


I select this code and tell Eclipse to format it. I would expect it to
translate the space indentation on the first two lines to tab
indentation (my options are set up to always prefer tabs for
indentation). However, it leaves the spaces indenting the first two lines.
Is this intended behavior? If my formatter options say use tabs for
indentation, why is it leaving the spaces?
I recognize that the formatter and its options have changed a lot since
2.x, so I want to know if this is a bug or if there might be some other
options to try tweaking.

TIA,
Eric
Re: [3.0M9] Formatter not obeying tabs vs. spaces settings? [message #165890 is a reply to message #165873] Fri, 25 June 2004 14:34 Go to previous messageGo to next message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
Did you just format the selected method, or the entire file (ie. did you
have a selection when invoking 'Format'?)?

Not quite sure, but: if you just select the method for formatting, the
formatter may not necessarily change the initial indentation. Try
formatting the entire file.

-tom

Eric Rizzo wrote:
> I am working with an existing code base that, unfortunately, uses an
> inconsistent mixture of tabs and spaces for indentation.
> So as I touch various files, I am trying to re-format them to use tabs
> consistently. Problem is, the formatter is not doing what I expect when
> I re-format existing code.
> Here's an example method that is formatted weirdly:
>
> <sp><sp><sp><sp>public void foo()
> <sp><sp><sp><sp>{
> <tab>doSomething();
> <tab>doSomethingElse();
> <tab>}
>
> Which looks like this:
> public void foo()
> {
> soSomething();
> doSomethingElse();
> }
>
>
> I select this code and tell Eclipse to format it. I would expect it to
> translate the space indentation on the first two lines to tab
> indentation (my options are set up to always prefer tabs for
> indentation). However, it leaves the spaces indenting the first two lines.
> Is this intended behavior? If my formatter options say use tabs for
> indentation, why is it leaving the spaces?
> I recognize that the formatter and its options have changed a lot since
> 2.x, so I want to know if this is a bug or if there might be some other
> options to try tweaking.
>
> TIA,
> Eric
Re: [3.0M9] Formatter not obeying tabs vs. spaces settings? [message #166089 is a reply to message #165890] Mon, 28 June 2004 22:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.rizzoweb.com

Tom Eicher wrote:

> Did you just format the selected method, or the entire file (ie. did you
> have a selection when invoking 'Format'?)?
>
> Not quite sure, but: if you just select the method for formatting, the
> formatter may not necessarily change the initial indentation. Try
> formatting the entire file.

Yes, this is only a problem when formatting the selection as opposed to
the entire file. I guess what I want to know is if this is "intended"
(ie, there is a justification for it being this way). If not, I'll file
a bug for it.

Eric
Re: [3.0M9] Formatter not obeying tabs vs. spaces settings? [message #166137 is a reply to message #166089] Tue, 29 June 2004 05:44 Go to previous message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
> Yes, this is only a problem when formatting the selection as opposed to
> the entire file. I guess what I want to know is if this is "intended"
> (ie, there is a justification for it being this way). If not, I'll file
> a bug for it.

You should, with a detailed case of what you select and format, what you
expect to see and what you get.

-t
Previous Topic:Converting /* .. */ to // comments?
Next Topic:How to set header contents when printing code
Goto Forum:
  


Current Time: Sun Oct 06 14:20:02 GMT 2024

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

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

Back to the top