Search code examples
eclipseeclipse-pdt

Use tab indentation for one-off file when Eclipse is configured to use spaces indentation without chanding preferences


I'm using Eclipse for PHP Developers (PDT). Normally I use spaces instead of tab characters for indentation. However, I'm editing someone else's file who indents using tabs and I want to preserve indentation style while editing their file. This is turning out to be difficult because whenever I press the Tab key it inserts spaces. I don't want to change my configuration to use spaces instead of tabs as I'll have to remember change it back. Is there a way I can insert a literal tab character?

I've tried copying a existing tab character in the file yet past results in spaces being inserted!


Solution

  • While I haven't found a way of inserting a literal tab character, with the AnyEdit Tools add-on installed I've found this simple procedure works for me:

    1. Edit the file ignore the whitespace inconsitencies.
    2. Once finished edits, right-click and select Convert > Spaces to Tabs.

    Should work the other way round if one was normally used to Tab indentation.