Eclipse: Stripping whitespace at EOL

Discussion in 'Java' started by Tim Tyler, Jul 12, 2005.

  1. Tim Tyler

    Tim Tyler Guest

    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/ Remove lock to reply.
     
    Tim Tyler, Jul 12, 2005
    #1
    1. Advertising

  2. 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
     
    Andrew Thompson, Jul 12, 2005
    #2
    1. Advertising

  3. Tim Tyler

    Roland Guest

    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_/ /__/
    / \ /_/ / \
     
    Roland, Jul 12, 2005
    #3
  4. Tim Tyler

    Tim Tyler Guest

    Andrew Thompson <> 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/ Remove lock to reply.
     
    Tim Tyler, Jul 12, 2005
    #4
  5. On Tue, 12 Jul 2005 21:41:31 GMT, Tim Tyler wrote:
    > Andrew Thompson <> 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
     
    Andrew Thompson, Jul 12, 2005
    #5
  6. Tim Tyler

    Dale King Guest

    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
     
    Dale King, Jul 16, 2005
    #6
  7. Tim Tyler

    Tim Tyler Guest

    Dale King <> 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/ Remove lock to reply.
     
    Tim Tyler, Jul 16, 2005
    #7
  8. Tim Tyler

    danielson317

    Joined:
    Sep 15, 2011
    Messages:
    1
    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.
     
    danielson317, Sep 15, 2011
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Jefferies
    Replies:
    1
    Views:
    1,167
    Andy Jefferies
    Jun 26, 2003
  2. Michael Angelo Ravera

    Eating whitespace but not eol

    Michael Angelo Ravera, Oct 1, 2007, in forum: C++
    Replies:
    4
    Views:
    436
    Pete Becker
    Oct 1, 2007
  3. ryan k

    Stripping whitespace

    ryan k, Jan 23, 2008, in forum: Python
    Replies:
    22
    Views:
    848
    Reedick, Andrew
    Jan 24, 2008
  4. Taylor Strait
    Replies:
    13
    Views:
    400
    Chris Gernon
    Dec 28, 2006
  5. Douglas Wells
    Replies:
    8
    Views:
    160
    Nobuyoshi Nakada
    Jan 27, 2007
Loading...

Share This Page