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?
IDEA has a “smart tabs” option that you can turn on: If this check box is selected, IntelliJ IDEA inserts tabs for indentation and reformatting, but fine alignment to a necessary column is done only via spaces. This is done in order to preserve visual representation of the source code, when the Tab Size is changed.
To enable this feature in IntelliJ, you must open the Settings dialog ( Ctrl+Alt+S ) and navigate to the Editor | General | Appearance tab. In this tab you need to enable the Show whitespace option. In addition, you can individually enable/disable which whitespaces to show: leading, trailing or inner.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With