To answer the "what do we do about it?" part of the question, I'd suggest fixing one thing that has annoyed me, and might be part of the cause of the problem (though I have no evidence for this). This annoyance is the Tab key behavior. So far only Antoine Pelletier has mentioned it in a comment, but I think it needs to be discussed, even if the discussion is only "No, we have evidence that that's not going to help".
Currently, if you're editing an answer and you hit Tab or Shift-Tab, the cursor focus leaves the edit box and goes elsewhere, either to the "Post Your Answer" button or to the Search box in the page header. This is appropriate behavior for a website, but when I'm typing an answer into Stack Overflow, my brain is in "code editor" mode -- which means that I expect Tab and Shift-Tab to indent or dedent.
I'd like to see the answer-edit box capture the Tab and Shift-Tab keystrokes and, instead, have them indent or dedent the currently selected block. (Or, if no block of code is selected, Tab would insert indentation spaces* at the current position, and Shift-Tab would dedent the current line). If this is implemented, it might also be nice to capture the Backspace key and have it act in an indentation-aware fashion, deleting one "level" of indentation (4 spaces by default).
One possible complication to all this is that the code that people are inserting may have all kinds of different internal indentation. But since Markup requires 4 spaces of lead indentation to define a code block, that's what Tab and Shift-Tab should do: indent the selected lines just enough that they can become a code block. That way, I can type something like:
def sample_python_code():
print("I like 2 space indentation")
if True:
print("but only when answering Stack Overflow questions")
if False:
print("because I like not having a horizontal scrollbar when I type a lot")
into the answer editor. When I select those lines (or the 20 lines of a real code example) and hit Tab, it will insert precisely four spaces at the front, to become:
def sample_python_code():
print("I like 2 space indentation")
if True:
print("but only when answering Stack Overflow questions")
if False:
print("because I like not having a horizontal scrollbar when I type a lot")
which, in turn, becomes a proper code block that looks like the first example in this answer. (This example got recursive in a hurry, since I had to use a code block to show what I meant.)
I have no evidence that the lack of Tab-key functionality is causing this issue. After all, users bothered by it (like me) could easily just highlight a code block and hit the {}
button, or else copy their code into any programming editor and hit Tab once to insert the four spaces they need. But it's still worth discussing, since it's a UX principle that any obstacle you put in the path of your users will hinder at least some of them from accomplishing the goal. So perhaps the lack of Tab-key functionality is part of the cause; and even if it isn't, it's still something that would be nice to have.
* To try, perhaps in vain, forestall the inevitable "tab characters vs. space characters for indentation" debate... I propose that the behavior of the Tab key be exactly identical to what happens now when you hit the {}
button in the answer editor. Since that button inserts space characters, so would the Tab key in the answer editor.