If you’re doing everything in the Command Window, there is no going back.
I would open and save a script file for your exercises and run the script file instead. You can Comment (use % in the first column) the lines you want to save but do not want to run for later reference as you go through your textbook. (I have a script file like that to test and save code I post here on Answers.) You can also use comments to refer to specific exercises on specific pages with respect to your code, so you can refer to it later.
Best Answer