How to print code

I'm new to using the Arduino IDE and I'd like to know if anyone can give me a tip on how to print the code I'm building. I need to compare two programs I wrote to unify them and I prefer to do this on paper before starting to change them.
Copying and pasting the code into a text program is very bad because it does not preserve the code formatting

Welcome to the forum

I am guessing that you are using IDE 2.x

If so, then you cannot print the code from the IDE because apparently it is not a feature that programmers require

The strange thing is that they seemed to require it when using IDE 1.x

You can copy & paste into Windows Notepad and print from there. But you'll loose any colors/highlighting.

I'm doing this, but without the formatting it's more boring to analyze and I'm looking to see if there's an easier way to print...
Thanks for your suggestion

Open the sketch in IDE 1.x and print it from there

Thank you for your answer and I agree with you, in fact it is strange because several times throughout my career I needed to print source code even for use by auditors and in legal matters.

This may be of interest

If you are going to use a notepad on Windows, then get notepad++. It does at least have line numbers and supports syntax highlighting for a number of programming languages. Another possible and similar option is Gedit.

You can also use the FC.exe command line tool to compare similar files and highlight the differences.

^https://www.howtogeek.com/206123/how-to-use-fc-file-compare-from-the-windows-command-prompt/

You can also print from notepad++ or gedit if you wish.

I followed your suggestion, downloaded Arduino 1.8 and printed with it, but in black and white, the colors didn't come out, but at least it preserved the code indentation.
Thanks a lot!

Thanks,
I liked your suggestions for Gedit and Notepad++, I'm going to download and test tomorrow. File comparison works well for different files, but comparing lines of code is more complicated.
A some years ago I developed a tool to document code and ended up adding comparison features and it was very useful because the projects were huge and the tool even compared existing procedures in databases. We used this tool to compare development and production environments to ensure a safe deployment.
Today these tools are already available, but in the days of dinosaurs like me, they weren't available and we had to develop them...
Those were fun times....

I couldn't wait until tomorrow, I downloaded notepad++, installed it and did the print test.
At first, without doing any customization, it looked really good! Numbered lines of code with the main commands in different colors.
It was an excellent suggestion and I recommend it to anyone who has the same need.
Thank you very much!
Tomorrow I'm going to test Gedit for comparison terms and I'm going to post my opinion about it here too.