Reputation: 55555
How can I remove lines that only contain spaces when using Eclipse Find/Replace prompt. I checked the "Regular Expression" check box, and tried the following, neither of which worked.
^[:space:]*$
and
^\s*$
Upvotes: 36
Views: 35045
Reputation: 3303
Use this below pattern as shown below in any IDE Editor
^\s*\n
Upvotes: 0
Reputation: 3852
As already suggested, regular expression and replacement is the solution, but such response would have been saving some minutes to me:
Upvotes: 0
Reputation: 716
cheer!
Upvotes: 4
Reputation: 41
I was suprised that for XML files edited with Eclipse there is a good solution:
Select the checkbox value named 'Clear all blank lines' in Formatting panel Window->Preferences->XML->XML Files-> Editor
Save and use the "Ctrl+Shift+F' shortcut
The blank lines will dissappear!
Upvotes: 4
Reputation: 141
Many thanks to lamamac.
In genereal, when you want to do search replace with regular expressions in eclipse the $ sign doesn't work as it should.
Use '\s*\n
' instead of '$
'
Upvotes: 0
Reputation: 528
This one worked for me for years:
Replace this: [\t ]+$
With nothing
Hope this helps!
Upvotes: 2
Reputation: 17761
sry this might be an different answer but you can set the number of blank lines you wish to have after fields, methods and blocks in the formatting dialog of the eclipse preferences. then you can hit ctrl-shift-f to automatically format your code depending on your custom definitions.
have fun!
Upvotes: 7