Know when to stop. Our brains, like any other muscles and body parts are subject to overuse and exhaustion. I found myself too many times being unproductive because I had gone for long periods of non-stop coding (and/or designing)...and honestly this is where bugs occur, where you make stupid mistakes, syntax typos and even worst. After a couple of hours stop, take a walk, go to the gym (this is what I do), do something else but reading or working on code.
Also, use the right tools, autocompletion saves hours of coding (and also stupid typos), git/versioning saves you from madness and going back in time when needed...and personally my tool of choice is VSCode which is constantly growing with dozens of tools that WILL make you more efficient with your time and code.