What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

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

bla
bla

it looks like

bla

bla

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

    bla
    bla

The display is

    bla
bla

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.

6  
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
2  
Is this a rant, or are you actually asking a question? –  slugster Apr 18 '12 at 12:21
add comment

1 Answer

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
add comment

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