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....
6 Answers
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.
And when you format the code all unwanted blank lines will be removed.
-
Better answer than using regex, but didn't work in luna – Deckard Apr 21 '15 at 08:52
Find: ^\s*\n
Replace with: (empty)

- 7,783
- 5
- 31
- 41
-
this problem of setting but i dont know how can i resolved this issue. – Ankur Loriya Oct 05 '12 at 05:55
-
Don't forget to choose "Regular expressions" in the find and replace dialog. – Marc Johnen Nov 20 '20 at 13:36
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.

- 388
- 5
- 11
-
-
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
-
Due to your eclipse setting.
you can change your setting from preferences.

- 363
- 1
- 11
-
-
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 – Mohd Kalimullah Sheikh Oct 05 '12 at 06:05
- Find and replace as Regular Expressions with ^\s*\n
- Press Ctrl + Shift + f
- Press Ctrt + Shift + o

- 3,444
- 7
- 53
- 83
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.

- 561
- 6
- 11