12

I know how to do that in question or answer post. But how do I write a comment post which contains multiple spaces?

I want to write this in a comment:

print    ("string")

I tried:

  • Using ``, but spaces didn't get preserved.
  • Using  , but it get printed exactly the way it is.
  • Using <code></code>, same result as first one.
  • Using <pre></pre>, same result as first one.

I am using Linux.

4
  • 4
    Related: Multiple spaces in code in comments get merged into one (but I suspect the answer you're going to end up getting is "why would you want to do that" followed by "if it's that important, it shouldn't be a comment.")
    – Pops
    Commented Mar 22, 2013 at 16:23
  • Actually, the answer is an actual way to leave multiple spaces in comments. Commented Mar 22, 2013 at 16:52
  • 1
    Note that using non-breaking spaces in code samples are very confusing if people would copy & paste.
    – Arjan
    Commented Mar 23, 2013 at 11:07
  • @Santosh, I just want to let you know that what the poster said was inexcusable. Know that we know him well, and he's proven adept at bypassing the blocks we've put in his path. If it helps, he's pretty severely mentally ill. He's not attacking you, really, more than he's flagellating himself. Commented Aug 5, 2013 at 4:43

3 Answers 3

6

If you're using windows, than you can hold alt and press 255. You can leave multiples of those spaces.

Apparently you have to do this on your number-pad(the row of numbers above your qwerty part doesn't work apparently).

  ▲
▲ ▲

8
  • 1
    @dasblinkenlight it should..... I've just checked into it a bit, and it doesn't seem to work unless you use the square number pad if you have one Commented Mar 22, 2013 at 17:02
  • @dasblinkenlight and it should work on firefox/windows, considering that's the main platform I use, and I've done it many times. on that. Commented Mar 22, 2013 at 17:03
  • @dasblinkenlight does it not work when numlock is on? Commented Mar 22, 2013 at 17:08
  • Removing my comments as no longer relevant... Commented Mar 22, 2013 at 17:27
  • @SamIam I use Linux and doing so first takes me to 2nd tab followed by 5th tab. Is there any workaround this (any application or so?)? Commented Mar 23, 2013 at 4:56
  • If I do Alt+255 on Windows (zh-HK) I get ÿ instead of any spaces.
    – Alvin Wong
    Commented Mar 23, 2013 at 7:12
  • @AlvinWong: You can edit the post from the console (using \u00a0), and add the text in with some jQuery.
    – nhahtdh
    Commented Mar 23, 2013 at 8:19
  • +1. Noobs can't triforce. Commented Mar 23, 2013 at 8:28
3

For Linux:

Based on @SamIam's answer and this post on SuperUser, I got the solution for my own question.

On Linux, we can use Ctrl + Shift + u followed by the unicode hex code of the character to insert that character. So taking reference from this post I found that hex code for a space is 00A0 or simply A0 (0s before the alphabate doesn't matter).

So in my case I could do Ctrl + Shift + u followed by A0.

Google for unicode hex table to find some useful hex codes you can use in linux.

1
  • Now I can do print           ("string"). Commented Mar 23, 2013 at 11:17
0

On a Mac: press Option + Spacebar to get a non-breaking space, like   for   example   here  .

Note, however, that it looks like a space, but is not. Copy & paste will surprise people a lot, if used in a code sample. Also note that Unicode magic is inserted in comments (not just in `code`) whenever no whitespace was seen for about 80 characters, to enforce line wrapping. Such non-breaking space does not count as whitespace, so increases the chance that the Unicode magic is applied, which again is confusing for copy & paste.

And if only done to get some specific formatting, then note that things look different on mobile, which does not have a fixed width. One cannot really control how things look.

1
  • And like for   example   here.
    – Arjan
    Commented Mar 23, 2013 at 10:46

You must log in to answer this question.

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