35

Is there an easy way to code format on a mobile device?

My phone simply wouldn't allow me to prefix each line with whitespace, auto correcting it out. There also doesn't appear to be a code button (though selection is hard anyway) or Markdown help that I can see on a mobile.

This is the site on a mobile device rather than any apps, etc.

Here's a screenshot of my mobile view:

Enter image description here

As a note, I'm running Chrome on Android 4.4.2, and in my case I'm using a Motorolla G phone, but I believe my Google Nexus 7 exhibits the same behaviour.

11
  • @Bart I don't see the usual buttons on a mobile sized device + selection is a of on a mobile
    – Ian
    Commented Jun 15, 2014 at 22:06
  • 1
    With mobile Safari (->iPhone) these buttons show up, work normally and are easily clickable. (Thought I'd add this issue is not on all mobile browsers.)
    – 11684
    Commented Jun 16, 2014 at 7:46
  • @11684: Thanks, will add my browser details.
    – Ian
    Commented Jun 16, 2014 at 9:04
  • I use my nexus 4 and nexus 7, and I've never had any issues entering code - it doesn't present the buttons to do it, though - you just enter spaces or ` ticks `
    – Marc Gravell Mod
    Commented Jun 16, 2014 at 9:15
  • @11684 Where do you see these buttons on mobile Safari? IIRC, there are simply no formatting buttons on the mobile version of Stack Overflow. Do you happen to use the desktop version of the site on your iPhone?
    – Antony
    Commented Jun 16, 2014 at 9:15
  • @MarcGravell: Ah, ticks may solve the problem - I was aware you could use them in comments, but not in Questions/Answers. My mobile wouldn't allow me to insert a space infront of some JavaScript code, it just ignored my key presses, I believe due to auto-correction.
    – Ian
    Commented Jun 16, 2014 at 9:31
  • 1
    @Ian that's odd; what browser is it? I use stock chrome, and it works fine.
    – Marc Gravell Mod
    Commented Jun 16, 2014 at 9:44
  • @MarcGravell: I was using stock chrome too. It did behave strangely - the first 2 lines of code allowed me to add spaces just fine, it just wouldn't let me for further lines.
    – Ian
    Commented Jun 16, 2014 at 10:24
  • For what it's worth, I've never seen any of the formatting buttons on Windows Phone (7, 8 and even 8.1). Prefixing lines with spaces is annoying (double space inserts a .) but doable. Is there a reason the buttons are hidden on mobiles?
    – Bojangles
    Commented Jun 16, 2014 at 14:19
  • 5
    @Ian, are you positive there was a hard-return before the lines you were unsuccessfully trying to indent? In other words, that it wasn't just line wrapping pushing it down to the next line? If it was line wrapping and not a hard return, adding a space at the perceived "start" of that line might not work, as the space would flow back up to the previous line. Just a thought.
    – Josh
    Commented Jun 16, 2014 at 14:43
  • why you don't use mobile application?
    – Emna Ayadi
    Commented Dec 26, 2016 at 17:09

2 Answers 2

29

Perhaps Stack Exchange should make their textareas non-autocorrectable (or at least give a hint to mobile browsers to not use autocorrect). This code works:

<textarea autocomplete="off" autocorrect="off"
        autocapitalize="off" spellcheck="false">
</textarea>

I actually discovered this HTML feature here: http://davidwalsh.name/disable-autocorrect

I frequently code for Stack Exchange on iOS and autocorrect is immensely annoying (always capitalizing my function names / replacing them with gibberish). This would be very useful to many people (I'm sure) if it was implemented.

Also, if this were to be implemented, perhaps the handle underneath the edit textarea could also be updated to respond to touchstart / touchmove?

8
  • 4
    Sounds like autocorrection is a terrible idea from the beginning. Commented Jun 17, 2014 at 7:31
  • 19
    Btu ten wed have lost of typoes apearring in psots
    – Cody Gray Mod
    Commented Jun 17, 2014 at 8:16
  • 6
    Expanding upon Cody's comment; no auto-complete and no auto-capitalization would be awful; posts contain actual English as well as code, don't forget. It'd be awesome however, if <textarea>'s support autocomplete and autocorrect being turned on and off programmatically, and SE can disable autocomplete and autocorrect whilst typing in code (i.e. whilst indented 4 spaces).
    – Matt
    Commented Jun 17, 2014 at 9:51
  • 4
    @Matt perhaps that's possible, if you added and removed the attributes with javascript. I'm going to play with this later and see if it works.
    – DankMemes
    Commented Jun 17, 2014 at 11:42
  • @Matt - presuming that code is the only place where you use non-dictionary words, which is not very necessarily the case on a place like StackOverflow.
    – chiccodoro
    Commented Jun 17, 2014 at 15:22
  • 1
    Sadly, from what I've tested, iOS7 (Chrome, Safari) does not support dynamically switching the attributes on and off. I have to blur the textarea and refocus (bring the keyboard up again) for the changes to update. I don't have an android to test on at the moment, but perhaps it will work...
    – DankMemes
    Commented Jun 17, 2014 at 16:50
  • I must be missing something but why is it necessary to use a <textarea> instead of a contenteditable div, or something?
    – Nebula
    Commented May 15, 2016 at 13:50
  • 1
    @towerofnix contenteditable <div>s tend not to work so well on mobile devices. I've had issues on both Android and iOS with some syntax highlighting editors (including not being able to select or position the cursor, and the cursor being offset from the text). It's just simpler and more convenient to use a <textarea>
    – DankMemes
    Commented May 15, 2016 at 17:25
10

I've come across similar issues myself and often just clicked the link at the bottom of the page to view the "Full Site", which gives you all of the content formatting controls.

It's not ideal but gets the job done.

enter image description here

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