Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we replace tab character with white space for existing Java code in Eclipse?

I am using Eclipse - mars. I need to replace tab character with white spaces in existing code. I did this:

Open Window->Preferences from menu bar.
Select Text Editors from tree menu.
Uncheck Insert spaces for tabs.

But this doesn't replace for existing code. Is there any simple way to do that, considering I have some 25 java files to do this.

like image 215
Teddu Avatar asked Dec 23 '16 09:12

Teddu


1 Answers

After you have changed your settings, you need it to be applied it to your code files. This can be done by formatting your code.

  • Windows: Ctrl + Shift + F (Control + Shift + F)
  • Mac: + Shift + F (Command + Shift + F)

  • Main menu: main menu > Source > Format

(from the answer How to auto-format code in Eclipse?)


As @StephaneM suggested:

Change your code style formatter to remove white spaces before and after assignments

To remove the whitespace before and after assignments (=).

like image 88
Luke Melaia Avatar answered Oct 26 '22 16:10

Luke Melaia