If you're writing a lot of code in them, it's probably better to put that code into libraries that get imported and reused.
And I do agree that default code environment is unbearable. Particularly the auto insertion of completing quotation marks, which has me continually fighting with the editor to get correct code into a tiny web text box.