16

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
  • 3,276
  • 8
  • 31
  • 58

6 Answers6

18

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.

jschroedl
  • 4,916
  • 3
  • 31
  • 46
J4cK
  • 30,459
  • 8
  • 42
  • 54
15

Find: ^\s*\n

Replace with: (empty)

Anshu
  • 7,783
  • 5
  • 31
  • 41
2

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.

Kano
  • 388
  • 5
  • 11
  • every new opened file has this problem. – Ankur Loriya Oct 05 '12 at 10:54
  • 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. – Kano Oct 05 '12 at 16:10
  • I get "Error Incompatible line delimiter near index 1748" – Dean_Wilson Feb 01 '13 at 02:39
1

Due to your eclipse setting.

you can change your setting from preferences.

1
  1. Find and replace as Regular Expressions with ^\s*\n
  2. Press Ctrl + Shift + f
  3. Press Ctrt + Shift + o
Sun
  • 3,444
  • 7
  • 53
  • 83
0

The good thing is that this is all well and good when you work alone;
The unfortunate side is that it also exposes "bad team cooperation" when you check in your files in the version control: there will be people who will gladly help you keep things consistent while there are many others who will ignore your pleas and keep overwriting your beautifully properly formatted code.

AlexD
  • 561
  • 6
  • 11