[ACCEPTED]-Remove blank line in Eclipse-eclipse

Accepted answer
Score: 96

Find: ^\s*\n

Replace with: (empty)


Score: 7

sry this might be an different answer but 6 you can set the number of blank lines you 5 wish to have after fields, methods and blocks 4 in the formatting dialog of the eclipse 3 preferences. then you can hit ctrl-shift-f 2 to automatically format your code depending 1 on your custom definitions.

have fun!

Score: 4
  1. for the find/replace operation, "\n\r\s" regex will work on windows, for unix based system, "\n\s" can be used
  2. as already suggested, you can format your code by Ctl+Shift+F
  3. for manual work, locate a blank line and press Ctl+D (Cmd+D on Mac) <- gives u satisfaction of killing the line with your own bare hands :)



Score: 4

I was suprised that for XML files edited 5 with Eclipse there is a good solution:

  • Select 4 the checkbox value named 'Clear all blank 3 lines' in Formatting panel Window->Preferences->XML->XML 2 Files-> Editor

  • Save and use the "Ctrl+Shift+F' shortcut

The 1 blank lines will dissappear!

Score: 2

This one worked for me for years:

Replace 1 this: [\t ]+$

With nothing

Hope this helps!

Score: 0

Many thanks to lamamac. In genereal, when 3 you want to do search replace with regular 2 expressions in eclipse the $ sign doesn't 1 work as it should. Use '\s*\n' instead of '$'

Score: 0

As already suggested, regular expression 3 and replacement is the solution, but such 2 response would have been saving some minutes 1 to me:

  1. click on ctrl+f
  2. use this replacement:

enter image description here

More Related questions