Here is some Mathematica code as it appears after writing it my text editor.

In a Mathematica note book I create a new Code cell with Cmd+8 (in OS X), and paste the code from the text editor into the cell. The gray background indicates the cell has the initialization cell property. Don't want that.

With the mouse cursor in the Code cell (or with the cell selected), hit Ctrl+8. The gray background vanishes. The cell no longer has the initialization cell property. It behaves like an input cell except it maintains the plain text formatting.

If you were to copy this code from a Mathematica notebook and paste it into one of this site's editing panes, it would still maintains its line formatting, so all that is needed after pasting is select the code and hit Cmd+K to get the following.
foo[x_, y_]:=
(* This is a comment *)
Module[{bar = {x, y}, this, that},
{this, that} = Thread[frob[bar]];
1 + this/that]
Update
Using Ctrl+8 may only work on OS X. The only indication of this keyboard shortcut comes from the Cell menu itself. See bellow

The ^8
appearing on right side of the indicated menu item is OS X's way of showing Ctrl+8 is available as a shortcut.