How to format questions in this forum

Sorry, I am new to this forum but already find it very helpful. I noticed that most posts have nicely formatted code snippets, but I couldn't figure out how to do it. When cut-and-paste from notebook() my code looks awful and unformatted.