Is there an easier way to copy pasted code on this forum?

Not sure I understand everything you want, but that’s the way you usually go about pasting code on the forum: