How to replace eclipse tab with spaces in java

Eclipse code editor, By default text intended with tab characters.

We can change this tab behaviour in eclipse in multiple ways.

Some programmers uses other text editors like Intelli IDEA, VSCode.

Each IDE has tab settings configured default.

You will get indentation style issues when you are importing non eclipse project. This post solves how to replace tab with spaces in code editor of 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 java code editor How do you replace tab with spaces in java eclipse?

  • Go to Windows Menu
  • Select Preferences Option, Popup window opened
  • Select java on left side options
  • Check Code style
  • Select Formatter option as seen in below screenshot
eclipse replace tabs with spaces in java
  • Create a new settings as seen below
eclipse change tabs with spaces in java
  • It opens new popup window and change the settings as seen below
eclipse change tabs with spaces in java
  • Finally apply and close popup window

Here is formatted code

package testing;

public class Test {

	public static void main(String[] args) {
		System.out.println("Welcome ");


if code is not indented as per space settings, select code in code editor, right click, context menu opened, Select source -> Correct Indentation or CTRL+L short cut to format the java

You can also do the same settings in php,javascript editors.

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
You'll get a notification every time a post gets published here.