{

How to replace eclipse 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 the eclipse.

As tabs are applied to the code editor. So based on your language, you can replace 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
eclipse replace tabs with spaces in java
  • Create a new setting as seen below
eclipse settings change tabs with spaces in java
  • It opens a new popup window and changes the settings as seen below
eclipse change settings tabs with spaces in java
  • 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 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.

THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.