Replace spaces with tabs using Eclipse

Joshua Hyatt picture Joshua Hyatt · Mar 6, 2014 · Viewed 83.7k times · Source

I downloaded some code from the Internet, and the four-space indentation is bugging the crap out of me. I tried to do a find and replace for "<4 spaces>" and replace it with "\t", but that just replaced all sets of spaces with the string "\t". How would I put a tab in the "replace" box?

Answer

Kohei Mikami picture Kohei Mikami · Mar 6, 2014
  1. Open Window->Preferences from menu bar.
  2. Select Text Editors from tree menu.
  3. Uncheck Insert spaces for tabs.

enter image description here

After that, run Format menu from context menu and save the file:

enter image description here