It's very difficult to post code on Stack Overflow using the mobile theme on an iDevice. I've tried indenting the code by 4 spaces, but I'm still getting an error that the code is not formatted correctly. Not to mention the fact that it's extremely tedious to do this by hand.

It would be much easier if we could just select all of the code and click a single button to format it automatically, much like we can already do using the full site. This seems like an important feature for Stack Overflow, even on the mobile theme. If we're going to be able to ask questions, we should be able to post snippets of code that accompany those questions. The FAQ even says that:

...the best Stack Overflow questions have a bit of source code in them...

Or is there another, existing solution to this problem that I'm missing?

  • 3
    What warnings do you get? From where? – Pekka Aug 10 '11 at 21:48
  • When i submit the post/answer I get this warning: Oops! Your answer couldn't be submitted because: Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon. – JonasG Aug 10 '11 at 22:46
  • 4
    @Maxner What is SE supposed to do about the fact that a touchscreen phone sucks for typing? Become a smartphone manufacturer? – user154510 Aug 11 '11 at 2:34
  • no, but they could maybe add a simple 'Code' button to the mobile site!? Also I was asking if there was a way to do it, I wasn't telling SE to change something, but now you have askesdfor it. – JonasG Aug 11 '11 at 4:00
  • So since there is no way to properly format code appart from short code snippets like CODE. But longer code is almost impossible to post, I'm not saying that I write a lot of code on my iPod, but if somebody needs simple code i just get it off google and paste it. And then I get the explained problem... – JonasG Aug 11 '11 at 4:10
  • 1
    By the way, I tried to turn this question into an actual question rather than just a maniacal rant. Feel free to roll back if you prefer rants... – Cody Gray Aug 11 '11 at 13:47
  • 4
    I think this is not all that crazy a request. Copying and pasting code is certainly possible with a phone. It would be nice to have an "indent" button, especially since it exists in the normal desktop UI anyway. – Adam Lear Aug 11 '11 at 13:49
  • My phone keyboard doesn't have backticks on it, so it's near impossible to post something with inline code formatting without a button that does the formatting. – sth May 5 '13 at 16:57
  • Another possibility is that you do the 4 spaces for the first line but the following lines are indented for you – jamylak May 6 '13 at 11:43
  • Could someone from SE post an answer please, I don't want my bounty to go to waste :( – It'sNotALie. May 7 '13 at 22:05

You must log in to answer this question.

Browse other questions tagged .