7

How to replace all tab characters in classes by sequences of white-spaces?

Project has 10K+ classes.

Have Community edition IntelliJ, how do I automate this process?

imtheman
  • 4,713
  • 1
  • 30
  • 30
Peter
  • 689
  • 2
  • 8
  • 20
  • `find . -name '*.java' -exec sed -i "" 's/ /c/g' {} \;` will do the trick (note: that space after the `s/` is a tab, not a normal space: http://stackoverflow.com/questions/2610115/sed-not-recognizing-t-instead-it-is-treating-it-as-t-why) – yshavit Aug 03 '15 at 14:31

2 Answers2

7

In IntelliJ you can do a find and replace across the entire project by doing ctrl-shift-r, or by going to Edit->Find->Replace In Path, make sure the 'Regular expression' box is ticked, then in the 'Text to find' box enter \\t and the 'replace with' box enter four spaces or whatever you want to replace the tabs with

You could do some magic with find and perl:

find . -name "*.java" -exec perl -i.bak -pe 's/\t/    /g' "{}" \;

This will find all files named something.java within the current directory and its subdirs, then call perl to replace all tabs with four spaces, and create a backup of the file before performing this substitution with the extension.bak

beresfordt
  • 5,088
  • 10
  • 35
  • 43
1

You can replace tabs with spaces with Notepad++:

Navigate in the menu bar to "Search→ Find in Files..." and fill the formular like below.

enter image description here

Binkan Salaryman
  • 3,008
  • 1
  • 17
  • 29