You would use the </> button on the toolbar to post text as preformatted, or you would use triple backquotes [ ``` ] on the lines preceding and following the pasted text. Either method would retain the formatting as seen on-screen for easier readability on our end.
Try editing the post that was mentioned and see what exactly was done when it was edited for you.