All spaces are replaced by tabs when ctrl + shift + f

works in eclipse, when I enter 'tab', it inserts 4 spaces, it works well. but after ctrl + shift + f to format all 4 places will be replaced with tabs.how to stop it?

+4
source share
5 answers

Window-> Preferences-> Java-> Code Style-> Formatter: Edit Active profile-> Indentation-> Tab Policy: select spaces

You cannot change the default profiles, so you must specify a new profile name, then click the "Apply" button, then the "OK" button. This may help to click the Apply button as soon as you return to the Formatter screen. Go back and look at the tab policy again to make sure your changes are saved.

+1
source

I don’t know which version of Eclipse you are using, but Eclipse 3.6 (for example) you can upgrade to

Window->Preferences->General->Editors->Text Editors->Insert spaces for tabs

This will change Eclipse to use spaces instead of tabs.

0
source

The place in the settings may differ depending on the version of Eclipse used. If you load the settings window, you can use the search function there to find "Formatters" and set your preferences for files of different types or in general.

0
source

Including the above suggestions, I recommend looking for a code style or style to get the coding standard used when requesting formatting a user code. It is possible that the code style uses tabs instead of spaces.

0
source

The only way that currently works is to use Ctrl-A Ctrl-X Ctrl-V for all the code after using Ctrl-Shift-F . This will replace all tabs with spaces.

0
source

Source: https://habr.com/ru/post/1436731/


All Articles