When I am learning a new library or programming language, I don't copy-paste. I type the code snippet manually.
In order of importance, the benefits of typing code are:
- You are actively thinking what you are typing. You are unconsciously learning the code as you read the text.
- You get extra time thinking how the copied code fits in your existing code.
- You get typing practice
I strongly believe that copy-pasting inhibits learning, that when I teach programming, I intentionally write on the whiteboard to force the students to type.
If I have an extra monitor, I would move the documentation there and start typing. But most of the time, I use my text editor's transparent mode so I don't have to resize my windows to fit a single screen.
Next time you are learning a new library or language, give typing a try. You'll be surprise at how effective this is.
(I do have an exception when the code snippet is more than 2 and a half pages long. But most tutorials group the relevant code while discussing them, so the typing isn't that heavy)