Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Eclipse: Stripping whitespace at EOL

Reply
Thread Tools

Eclipse: Stripping whitespace at EOL

 
 
Tim Tyler
Guest
Posts: n/a
 
      07-12-2005
Can Eclipse be configured to strip whitespace at EOL?

Either at every save - or in the formatter?

If so, what's the best way to do that?
--
__________
|im |yler http://timtyler.org/ http://www.velocityreviews.com/forums/(E-Mail Removed) Remove lock to reply.
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      07-12-2005
On Tue, 12 Jul 2005 12:59:33 GMT, Tim Tyler wrote:

> Can Eclipse be configured to strip whitespace at EOL?
>
> Either at every save - or in the formatter?


I do not understand what you mean by 'the formatter'.

Here, in Eclipse 3.0.2 , the keyboard actions, ^a ^F ,
removes whitespace from the ends of source lines.

Isn't ^F invoking the formatter?

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
 
Reply With Quote
 
 
 
 
Roland
Guest
Posts: n/a
 
      07-12-2005
On 12-7-2005 14:59, Tim Tyler wrote:
> Can Eclipse be configured to strip whitespace at EOL?
>
> Either at every save - or in the formatter?
>
> If so, what's the best way to do that?

I miss that feature in Eclipse too. It's useful (I know from JBuilder),
for instance when auto-indent adds "superfluous" whitespace everytime I
insert/type an empty line.

The only way that I know of to remove trailing whitespace is to use
Find/Replace with regular expression "[\t ]+$" (without the qoutes).
--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
Reply With Quote
 
Tim Tyler
Guest
Posts: n/a
 
      07-12-2005
Andrew Thompson <(E-Mail Removed)> wrote or quoted:
> On Tue, 12 Jul 2005 12:59:33 GMT, Tim Tyler wrote:


> > Can Eclipse be configured to strip whitespace at EOL?
> >
> > Either at every save - or in the formatter?

>
> I do not understand what you mean by 'the formatter'.


See Preferences -> Java -> Code style -> Formatter.

> Here, in Eclipse 3.0.2 , the keyboard actions, ^a ^F ,
> removes whitespace from the ends of source lines.
>
> Isn't ^F invoking the formatter?


Try typing "// " (without quotes) - on a blank line - and then
performing the above actions.

The formatter can remove /some/ spaces - but doesn't seem to deal with
all of them
--
__________
|im |yler http://timtyler.org/ (E-Mail Removed) Remove lock to reply.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      07-12-2005
On Tue, 12 Jul 2005 21:41:31 GMT, Tim Tyler wrote:
> Andrew Thompson <(E-Mail Removed)> wrote or quoted:
>> On Tue, 12 Jul 2005 12:59:33 GMT, Tim Tyler wrote:

>
>>> Can Eclipse be configured to strip whitespace at EOL?

...
>> I do not understand what you mean by 'the formatter'.

>
> See Preferences -> Java -> Code style -> Formatter.


Right. Eclipse is not one of my more common IDE's
( I was seeking your help with it some time ago when I
screwed up the settings on an earlier version of Eclipse. )

I more commonly use TextPad, which automatically trims
all whitespace at the end of lines (none of this
'configurable' crap!), or JBuilder, which seems to
do it flawlessly.

>> Here, in Eclipse 3.0.2 , the keyboard actions, ^a ^F ,
>> removes whitespace from the ends of source lines.

...
> Try typing "// " (without quotes) - on a blank line - and then
> performing the above actions.


Uh-huh.. Oooh..

> The formatter can remove /some/ spaces - but doesn't seem to deal with
> all of them


You could try swi.. No, maybe I shouldn't go there.

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
In Hypno-Vision
 
Reply With Quote
 
Dale King
Guest
Posts: n/a
 
      07-16-2005
Roland wrote:
> On 12-7-2005 14:59, Tim Tyler wrote:
>
>> Can Eclipse be configured to strip whitespace at EOL?
>>
>> Either at every save - or in the formatter?
>>
>> If so, what's the best way to do that?

>
> I miss that feature in Eclipse too. It's useful (I know from JBuilder),
> for instance when auto-indent adds "superfluous" whitespace everytime I
> insert/type an empty line.
>
> The only way that I know of to remove trailing whitespace is to use
> Find/Replace with regular expression "[\t ]+$" (without the qoutes).


Actually, Eclipse has functionality to remove trailing whitespace, but
for some reason they don't expose it by default.

If you go to the key bindings, select modify and select File for the
category you will see that there is a Remove trailing whitespace that
can be bound to a key.

I don't see any way to actually add that to the menus.

To do it automatically check out the AnyEdit plugin:
http://andrei.gmxhome.de/anyedit/

--
Dale King
 
Reply With Quote
 
Tim Tyler
Guest
Posts: n/a
 
      07-16-2005
Dale King <(E-Mail Removed)> wrote or quoted:
> Roland wrote:
> > On 12-7-2005 14:59, Tim Tyler wrote:


> >> Can Eclipse be configured to strip whitespace at EOL? [...]


> > I miss that feature in Eclipse too. It's useful (I know from JBuilder),
> > for instance when auto-indent adds "superfluous" whitespace everytime I
> > insert/type an empty line.
> >
> > The only way that I know of to remove trailing whitespace is to use
> > Find/Replace with regular expression "[\t ]+$" (without the qoutes).

>
> Actually, Eclipse has functionality to remove trailing whitespace, but
> for some reason they don't expose it by default.
>
> If you go to the key bindings, select modify and select File for the
> category you will see that there is a Remove trailing whitespace that
> can be bound to a key.


Thanks. Doing it on save would be nice - but I don't think
the Eclipse folk have got the ability to easily execute a
series of actions on a keypress yet - without writing code.

Your http://andrei.gmxhome.de/anyedit/ looks like it would do
exactly what I want, though.
--
__________
|im |yler http://timtyler.org/ (E-Mail Removed) Remove lock to reply.
 
Reply With Quote
 
danielson317 danielson317 is offline
Junior Member
Join Date: Sep 2011
Posts: 1
 
      09-15-2011
To remove white space on save open preferences.

Then select the language you use such as php.
then editor->'save actions'

Select the checkbox that says "remove trailing whitespace"

For javascript got to 'save actions' select "Perform the selected actions on save"
Check "Additional Actions" and click on configure.
choose the "code organizing" tab

Check "Remove trailing whitespace"

This will remove trailing white space from all lines every time you save. You can optionally ignore empty lines.

Hope that helps. I am using zend studio but all eclipse installs are fairly similar.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stripping whitespace ryan k Python 22 01-24-2008 03:30 PM
Eating whitespace but not eol Michael Angelo Ravera C++ 4 10-01-2007 09:10 PM
Problem with stripping leading whitespace in here documents Douglas Wells Ruby 8 01-27-2007 07:46 AM
Strip is not stripping trailing whitespace Taylor Strait Ruby 13 12-28-2006 05:04 PM
Stripping whitespace around certain elements Andy Jefferies XML 1 06-26-2003 11:29 AM



Advertisments