How to replace tab with spaces in java
Eclipse code editor, By default text, is intended with tab characters.
We can change this tab behavior in eclipse in multiple ways.
Some programmers use other text editors like Intelli IDEA and VSCode.
Each IDE has tab settings configured by default.
You will get indentation style issues when you are importing non-eclipse projects. This post solves how to replace tabs with spaces in the code editor of eclipse.
As tabs are applied to the code editor. So based on your language, you can replace the tab with spaces.
In this tutorial, You will use a Java code editor. How do you replace tabs with spaces in java eclipse?
- Go to Windows Menu
- Select Preferences Option, Popup window opened
- Select java on the left side options
- Check the Code style
- Select the Formatter option as seen in the below screenshot
- Create a new setting as seen below
- It opens a new popup window and changes the settings as seen below
- Finally, apply and close the popup window
Here is the formatted code
package testing;
public class Test {
public static void main(String[] args) {
System.out.println("Welcome ");
}
}
if the code does not indent as per space settings, select code in a code editor, right-click, context menu opened, Select source -> Correct Indentation or CTRL+L shortcut to format the java.
You can also do the same settings in PHP, and javascript editors.