Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Possible Duplicate:
How do I format my code blocks?

All the time I post a code sampe on SO, the display is not as desired. Here some examples with simple text from a notepad document:

1) no whitespaces, beginning of the lines


it looks like



2) text has one tab (alternatively: 4 spaces) in each line before the text


The display is


I nearly every time have to do a lot of rearranging of the code to make it look nicely.

share|improve this question

marked as duplicate by Time Traveling Bobby, Cody Gray, Jeff Atwood Apr 19 '12 at 5:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Indent code by four spaces. No tabs, tabs are evil. – Daniel Fischer Apr 18 '12 at 12:11
please see my edit – AGuyCalledGerald Apr 18 '12 at 12:15
You still have tabs in that. I checked. – Daniel Fischer Apr 18 '12 at 12:20
Is this a rant, or are you actually asking a question? – slugster Apr 18 '12 at 12:21
up vote 4 down vote accepted

To format code properly, have a blank line before and after each code block and begin each line of code with four spaces. Spaces, ASCII 32, 0x20. No fancy stuff like tabs or non-breaking spaces.

The easiest way to get that is to paste the code, select it and press Ctrl+k or click on the {} icon above the text area.

If you have tabs in the code itself, that may or may not cause funny-looking indentation, but it is absolutely essential that the code lines begin with four spaces.

share|improve this answer

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