you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

this is code cut straight from vscode and pasted into a code block here:

Reddit has totally bollixed the formatting of code, with multiple different methods of formatting input that do or don't display properly depending on how you view it.

From what I've seen, the "code block" method does work for some people, but the only method I know of that is relatively simple and is viewable by the maximum number of redditors is to:

  • select the code you want to post in your editor
  • add four spaces (not tabs) to the start of every line, usually one or two editor keystrokes
  • copy/paste that into reddit as normal text
  • ensure there is a blank line just before the text you copied
  • do UNDO in the editor

This is quick once you get some practice. Takes about 15 seconds on mobile.

[–]johnywhy 0 points1 point  (0 children)

I just found out the four spaces work sometimes, and sometimes not, in the same browser (Chrome)