13

I feel very silly asking this question, but here goes. :)

I've configured Eclipse to insert spaces instead of tabs, but I'm working on a Makefile, which requires literal tab characters (see Can you make valid Makefiles without tab characters? for a good explanation).

So how do I type one, short of opening the Text Editors preferences, unticking the "Insert spaces for tabs" option, clicking Apply, and then undoing all of that when I'm done editing the makefile?

Community
  • 1
  • 1
Josh Glover
  • 25,142
  • 27
  • 92
  • 129

3 Answers3

11

Only way I can find to do it in Eclipse (version=Juno) was to type say XXX where I wanted the tab character and then do a find/replace. Switch on regexp matching in the find and put XXX as find with \t as the replace. Painful but works.

fruitcakegsi
  • 111
  • 1
  • 2
8

If you're using the Eclipse's built-in Makefile editor (included in the C++ package I believe), tabs should be literal.

tvStatic
  • 921
  • 1
  • 9
  • 26
  • Sorry, I should have been more clear. I **want** spaces instead of tabs, except in the makefiles. :) – Josh Glover Apr 07 '11 at 06:12
  • 1
    Then I would suggest using the Makefile editor as above. You get syntax colouring as well as overriding the tab behaviour. – tvStatic Apr 07 '11 at 06:31
  • Perfect! If you edit your answer to suggest using the Makefile editor, I'll accept it. :) – Josh Glover Apr 07 '11 at 06:36
  • 4
    For the sake of everyone reading this later, if you want to add the makefile editor to a version of Eclipse other than Eclipse for C/C++ developers (which has it out of the box), go to Help > Install New Software... > --All Available Sites -- > C and C++ Development > Eclipse C/C++ Development Tools – Konstantin Tarashchanskiy Dec 08 '11 at 19:32
1

Sorry, I don't appear to have enough points to comment on the accepted answer, but I wanted to add that although the Makefile editor allows tabs to be entered, it doesn't use tabs when indenting multiple lines with the tab key, or if you enter a tab in block selection mode. This made me think I couldn't enter tabs for a while (I should probably raise a defect report).

Nigel Scott
  • 643
  • 6
  • 12