Usually I use spaces to format code. But make in particular requires tabs in some parts of makefiles. How can I enter a tab in markdown such actual tabs are printed in the code section of my answer?

  • Why is this necessary? Why can't you just use spaces? – Cody Gray Apr 2 '13 at 23:53
  • 3
    @CodyGray: make explicitly requires tabs. See this answer for an explanation. – Dan Apr 2 '13 at 23:56
  • Okay, I'm not debating that. I don't understand why code needs to be 100% copy-pastable. Make users know that it requires tabs. – Cody Gray Apr 3 '13 at 4:08
  • @CodyGray: A makefile with spaces is a pretty subtle bug. I've been bitten by it before, and while I did include a warning I think it would be better to have both the warning and correct code. – Dan Apr 3 '13 at 6:19

It's not a very elegant solution (you lose syntax highlighting), but you can use a <pre> block and the HTML character entity &#9; for this.

E.g, the following:

&#9;-rm -f $(EXE) $(EXE).a *.o

renders as:

	-rm -f $(EXE) $(EXE).a *.o
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .