Today, I tried to paste some code into a forum answer, but it gets formatted as a single line. I worked around it by replacing all line endings into <p>, but the formatting is still not what you want (leading spaces are removed, etc).
It would be great if we can copy/paste code and keep the formatting, like for example on Medium.com:
Or another way to keep formatting of code lines as is.