This thread is intended as a short help file for all those struggling to post formatted code on the forum.
Code block formatting
Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the </> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting.
Note that all the </> button does is add three backticks ``` on the line before the code block and another ``` on the line after. If you wish you can type these rather than use the button.
Inline code formatting
Enclose the code snippet in single backticks, `...`.
Code can also be collapsed using the Hide Details feature. This can tidy up a thread with multiple code blocks and provides a ready-made index within the post.
This almost needs to be inbuilt into the reply editor, and suggested whenever the editor sees unformatted code.
Good job on the topic though; something to bookmark for regular use
Can you conditionally pin threads like this for newer members? Probably would be helpful if this was always at the top for people until they've made a few posts.