Eclipse: Stripping whitespace at EOL

T

Tim Tyler

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?
 
A

Andrew Thompson

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?
 
R

Roland

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_/ /__/
/ \ /_/ / \
 
T

Tim Tyler

Andrew Thompson said:
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 :-|
 
A

Andrew Thompson

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.
...
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. ;-)
 
D

Dale King

Roland said:
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/
 
T

Tim Tyler

Dale King said:
Roland said:
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.
 
Joined
Sep 15, 2011
Messages
1
Reaction score
0
Eclispes Preferences

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top