dcp
dcp

Reputation: 55467

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?

Upvotes: 28

Views: 16021

Answers (4)

Saikat
Saikat

Reputation: 16930

Steps:

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

enter image description here

Upvotes: 2

Pascal Thivent
Pascal Thivent

Reputation: 570615

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

enter image description here

Upvotes: 54

euzuro
euzuro

Reputation: 1

An addendum to this issue, if you do a multi-line indentation in an XML editor, you are out of luck (you'll get tabs):

https://bugs.eclipse.org/bugs/show_bug.cgi?id=168988

(Reported bug in Eclipse, but marked as WON'T FIX)

Upvotes: 0

Jason Gritman
Jason Gritman

Reputation: 5311

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.

Upvotes: 6

Related Questions