Presently, the ChatGPT UI gets a bit weird when it comes to printing.

If you just try to print the page, it will print a single page with the currently visible part of the content. Not exactly useful if ChatGPT just wrote for you a couple of hundred lines of code.

If you try to first preselect its answer (or several answers), and then pick Selection in the (Chrome, Edge) print dialog, it prints the whole thing, but the code is now without line breaks.

Without further ado, if you first go into the JavaScript debugger and enter the following code, things will work:

var styleSheet = document.createElement("style");
styleSheet.innerText = ":not(pre)>code.hljs, :not(pre)>code[class*=language-] { white-space: pre-wrap !important; }";

I am sure this issue will be addressed eventually, but for now, this method appears to work reliably.