First off, you are human and not an encyclopedia! I did a lot of copying and pasting of code early in my career of the syntax's that I could never remember.
I realized at some point that I was not learning those lines of code at all because I was being lazy by just copying/pasting them without really "saving" them to my own memory for the next time I had to use those lines of code.
If you want to be able to get to the point of being able to type those lines of code from memory, rather than blindly pasting them into your editor, open them up in a place where you can refer to them instead, and type them into the editor yourself. This is when having more than one screen comes in very handy!
The more you type the code yourself, the more you will remember them in the future. I don't know of many developer's who don't have to look at documentation from time to time because they've forgotten (or quite simply, don't know) something. IMO, being resourceful is much more valuable than having an entire language memorized!
This is why it is recommended that with whatever tutorials/books you are consuming, that you type out each of the examples on your own. Repetition is required if you want something to stay in your memory. You don't learn how to play a sheet of music by listening to someone else play it - although, that can be a valuable part of your learning process!
Quite frankly, you will learn more from your mistakes than from everything just working for you without any errors. Once you get "burned" from one "stupid mistake", you generally won't make that mistake again.