You can also select the text and hit the code symbol (see above). You could make a gist at gist.github.com, but it's nice for the people helping you to have everything in one place.
Also, using reprex will do the formatting for you.
For pointers specific to the community site, check out the reprex FAQ, linked to below.