Remove unwanted blank line eclipse editor

25,543

Solution 1

In eclipse preference setting you can remove all the unwanted blank lines. Eclipse: Window > Preferences > Java > Code Style > Formatter > Edit the formatter and following screen will pop up. enter image description here

And when you format the code all unwanted blank lines will be removed.

Solution 2

Find: ^\s*\n

Replace with: (empty)

Solution 3

Maybe you didn't understand what Anshu said. Do a Ctr-F on your editor. In the options, select Regular Expression. Enter ^\s*\n for the Find expression. Keep the Replace box empty. Replace All!

This of course might lead to removal of unwanted lines as well.

Solution 4

Due to your eclipse setting.

you can change your setting from preferences.

Solution 5

  1. Find and replace as Regular Expressions with ^\s*\n
  2. Press Ctrl + Shift + f
  3. Press Ctrt + Shift + o
Share:
25,543
Ankur Loriya
Author by

Ankur Loriya

Updated on April 16, 2021

Comments

  • Ankur Loriya
    Ankur Loriya about 3 years

    When i open any file in eclipse. it show alternative blank line after all the code lines and blank line. how can i remove it....

    enter image description here

  • Ankur Loriya
    Ankur Loriya over 11 years
    this problem of setting but i dont know how can i resolved this issue.
  • Mohd Kalimullah Sheikh
    Mohd Kalimullah Sheikh over 11 years
    whould you like send me version of eclipse IDE
  • Mohd Kalimullah Sheikh
    Mohd Kalimullah Sheikh over 11 years
    in Eclipse 3.7.2 you just right click on left side of editor , according to you print screen , you just RC below yellow triangle show
  • Ankur Loriya
    Ankur Loriya over 11 years
    every new opened file has this problem.
  • Kano
    Kano over 11 years
    Hmm, ok try this. Go to Window -> Preferences -> Java -> Code Style -> Formatter. Create a New Formatting profile. When you do that you will see a bunch of tabs. One of them will be 'Blank Lines'. Here there are a bunch of customization options. You can play with these and apply the new profile to your project.
  • Dean_Wilson
    Dean_Wilson over 11 years
    I get "Error Incompatible line delimiter near index 1748"
  • Deckard
    Deckard about 9 years
    Better answer than using regex, but didn't work in luna
  • Marc Johnen
    Marc Johnen over 3 years
    Don't forget to choose "Regular expressions" in the find and replace dialog.