I've plastered this script with comments so you can figure out what everything does quite easily. A lot of the keybinds are vim keybinds, so they might be easier to learn if you're familiar with vim (don't worry if not though)
Whatever you do, don't feel like this is set in stone. I went through many many iterations of my script before settling on this one. If you want to change something, do. It's yours now. An AutoHotKey install comes with some help pages which are genuinely useful for learning things, surprisingly. Rebind buttons, choose how the script should work for you and reload it on the fly. It's quick and easy, and will hopefully make you more productive, like it did for me.
Hope you enjoy, Cheers, ~Iain xx