These activities, since they are so different in nature, are best separated in time and space and tooling.
I produce in the early morning, sitting at my dining table in the living room, using a pen and paper. In the early morning your dreams still linger and your critical faculties are not yet fully awake. This makes it an ideal time for just producing stuff. I take this seriously in that I do not even allow myself to cross out words. Just keep on writing, and sort it out later. Later on the day I edit, sitting in my study and using a text processor.
As a side note, I would not recommend this practice for writing code.