Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse xml editor inserts tabs for spaces

I find that the Eclipse XML editor always inserts tabs for spaces even if you have the "Insert spaces for tabs" option checked under Window->Preferences->General->Editors->Text Editors.

You can open any XML file, and then do CTRL-SHIFT-F to format the file and you'll see this behavior (all your spaces will be replaced with tabs where appropriate).

I noticed this behavior with Ganymede, and just upgraded to Galileo today and was hoping it was fixed, but it seems to be the same.

Is this a bug, or am I doing something incorrectly?

like image 837
dcp Avatar asked Mar 10 '10 18:03

dcp


People also ask

Does Eclipse use tabs or spaces?

Eclipse - Tab to spaces And eclipse uses tabs for spaces by default. Tabs are always dependent on the environment and use 4 spaces in windows. If you use source code written with tab spaces, code is consistent across different environments.


3 Answers

Go to Windows > Preferences > XML > XML Files > Editor and select Indent using spaces:

enter image description here

like image 124
Pascal Thivent Avatar answered Sep 19 '22 15:09

Pascal Thivent


Not sure about this issue with the XML editor specifically, but I use the AnyEdit tools plugin to handle any tabs/spaces issues.

Once you've installed the plugin go to Preferences -> General -> Editors -> AnyEdit Tools and you can enable auto conversion of tabs to spaces (or vice versa) whenever you save a file. I find this very useful because it will also fix any files you've accidentally inserted tabs into when you change those files.

This plugin also provides a nice set text functions to use in the 'Convert' section of the right click menu of any text editor.

like image 43
Jason Gritman Avatar answered Sep 21 '22 15:09

Jason Gritman


Steps:

  • Open Eclipse -> Preferences
  • Go to XML -> XML Files -> Editor
  • Select the Indent using spaces option

enter image description here

like image 20
Saikat Avatar answered Sep 21 '22 15:09

Saikat