Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Remove trailing spaces in ecilpse

Reply
Thread Tools

Remove trailing spaces in ecilpse

 
 
pd
Guest
Posts: n/a
 
      12-07-2007
guys,

i am using eclipse 3.2.2. in my preferences i have set spaces for the
tab key. now when i run checkstyle on my code, it says that the lines
contain trailing spaces. can somebody tell me how i can fix this.

i have already set the setting to spaces, so what else can i change
now. thanks.
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      12-07-2007
pd wrote:
> i [sic] am using eclipse 3.2.2. in my preferences i [sic] have set spaces for the
> tab key. now when i [sic] run checkstyle on my code, it says that the lines
> contain trailing spaces. can somebody tell me how i [sic] can fix this.


Is "checkstyle" part of Eclipse?

> i [sic] have already set the setting to spaces, so what else can i [sic] change
> now. [sic] thanks.


Have you examined the lines that have trailing spaces?

When did the IDE add the spaces? What did you do, e.g., reformat the source,
hit newline, to which the IDE reacted by adding spaces at the end of the
line(s)?

Did it add them to all lines or just certain ones? If the latter, which ones?

Sometimes IDEs will indent an empty line and it will be nothing but spaces.

public void trailingSpaces()
{
int foo;

String s =
"The above line has two spaces, therefore it has trailing spaces.";
}

I haven't seen them add spaces at the end of non-empty lines, though.

I use a regex search-and-replace for " +$" => "". (Find "space-plus-dollar";
replace with empty string.) It'll take care of trailing spaces whether or not
the line has other stuff on it.

--
Lew
This post contains four requests for information. One of the five questions
is a rephrasing of the preceding one.
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      12-07-2007
Sorry, that's five questions, of which the sixth was a rephrase. I'll learn
my numbers someday.

--
Lew
 
Reply With Quote
 
Jeff Higgins
Guest
Posts: n/a
 
      12-07-2007

pd wrote:
> guys,
>
> i am using eclipse 3.2.2. in my preferences i have set spaces for the
> tab key. now when i run checkstyle on my code, it says that the lines
> contain trailing spaces. can somebody tell me how i can fix this.
>
> i have already set the setting to spaces, so what else can i change
> now. thanks.


This applies to Eclipse 3.3.0
I don't know if it applies to 3.2.2.

Go to Preferences, Java, Code Style, Clean Up.
Select Edit..., Select Code Organizing.
Check Remove trailing whitespace.
Select All lines, or Ignore empty lines.
Save your new profile.
You can run Clean Up from the Source menu.
*There is a way to run Clean Up when saving files,
but I cannot find it at this moment.
Note that this will apply ALL clean up rules.

You can also bind the Remove Trailing Whitespace
command to a key if you like.
Go to Preferences, General, Keys.
Check Include unbound commands.
Scroll to the Remove Trailing Whitespace command.
Select a key binding.
*I'm sure you can add this command to a menu item
if you wish, but I don't know how off the top of my head.



 
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
XSD to allow A-Z 0-9 and spaces, but not leading/trailing spaces johkar XML 2 12-10-2009 09:24 AM
Re: How to trim a String trailing spaces, but not leading spaces? Roedy Green Java 3 09-14-2008 02:10 AM
Re: How to trim a String trailing spaces, but not leading spaces? John B. Matthews Java 4 09-12-2008 05:28 AM
remove CR + trailing spaces Dan van Ginhoven Perl Misc 4 12-19-2007 11:08 PM
add ability to strip off leading/trailing spaces from email regularExpressionValidator? Les Caudle ASP .Net 0 03-07-2004 12:20 PM



Advertisments