Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 155 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

I have seen editing help, but I couldn't find how to add a space to the code snippet.

For example, this :

1
 2
 3

Should look like this (1 space in the last line) :
1
_2
_3
_

So, how do I add a line with only spaces in the code?

share|improve this question
    
Why do you need a blank line at the end? – Time Traveling Bobby Sep 8 '11 at 10:03
1  
@Straitjacket Take a look at this : stackoverflow.com/questions/7345649/… – BЈовић Sep 8 '11 at 10:50
    
Oh, output formatting...right. Missed that one. – Time Traveling Bobby Sep 8 '11 at 10:55
up vote 11 down vote accepted

You can do that using the HTML tags <pre><code> instead of indentation by 4 spaces:

<pre><code>1
 2
 3
&nbsp;</code></pre>

will give

1
 2
 3
 

Since you're using this for formatting output, you probably don't want syntax highlighting anyway; then you should omit the <code> and </code> tags. (Kinda obvious: don't use 'em if it ain't code.)

share|improve this answer

Enter a non-breaking space - not the &nbsp; version, the proper unicode version - after four normal spaces and the result is:

1
 2
 3
 

On Windows you enter this with Alt + ( Keypad 0, Keypad 1, Keypad 6, Keypad 0 ).

On Mac OS X you enter this with Alt + Space.

Unfortunately, I don't know how to enter it directly on Linux...

share|improve this answer
    
First I thought of this, too, but it has the disadvantage that if people copy-and-paste that code, they may catch the unicode space without noticing. – Hendrik Vogt Sep 8 '11 at 9:29
    
@Hendrik, hmmm true. But I guess that'll teach them to not copy-paste random code without checking it thoroughly? – DMA57361 Sep 8 '11 at 9:32
    
Your workaround is still good to keep in mind, but the nasty thing about the unicode space is that even with thorough checking it's hard to discover. – Hendrik Vogt Sep 8 '11 at 9:53

You must log in to answer this question.

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