Difficulty pasting code

It seems really hard for people to post code that is correctly indented.

Some people post screenshots of code from their editor.
Some people post code where the first line(s) are not indented and so aren’t formatted.

Some people add > to the first line so the whole thing looks like a quote, but then indentation doesn’t really work.

One would have thought that adding one level of indentation in your code editor before pasting would be so easy, but I didn’t think of doing that for ages. I added four spaces to each line manually.

Would it be possible to add github flavoured markdown code blocks? Three backticks on a new line starts the block, and three backticks on an empty line closes the code block. Like this…

unindented code
    indented code

Oh!?! It works!

Why didn’t I try that before? Because the friggin button for code formatting told me I had to indent everything with four extra spaces.

So, in the interests code readability, would it be possible to change the behaviour of the code formatting button so that it inserts lines with backticks when you select multiple lines of stuff?

2 Likes

I’m not sure if that’s modifiable but if it can I think that’s a good idea. I’ve noticed a lot of out of place indenting and I’ve been confused.

cc @smth who runs the forums.

Fixed now. The code editor will suggest code-fences instead of indentation now. Thanks for asking to look into it :slight_smile:

1 Like

And I didn’t even have to reload the page. :star_struck: