Kill your mouse
This post is about why keyboard shortcuts are worth the steep learning curve effort along with some strategies for learning them faster.
Speed is the obvious answer, but the benefits of acting faster on your machine are perhaps less immediately obvious.
- Brainflow - When you’re iterating quickly through different ideas while designing or debugging your code, you want to minimise the risk of forgetting or disrupting your current train of thought. Blazing fast navigation and code editing reduces the lag between what’s in your head and what’s on the screen. This helps you keep a clearer head because you have fewer “..and then I do this” actions cached in your memory. Moreover, the speedboost shortens your feedback loop on whether you’re hot or cold in the hunt for functional code.
- Badassery - You look like you know what you’re doing when you only need your keyboard to produce rapid on-screen results. Hollywood movies have blown this out of proportion somewhat, but the reality is that you’re displaying your investment in honing your coding craft when you’re dancing across the keys.
- Protect Your Hands - The time you spend at the keyboard or mouse adds up pretty quickly if you’re looking to be coding for the next decade or more of your life. The seconds that you shave from everyday movements are more like hundreds of hours in the long term that can substantially reduce the risk of injury. Not only should you use your mouse less, but you should try to be as efficient as possible with your typing.
- It’s actually pretty easy to pick up shortcuts for your current workflows, guess at the shortcuts of new programs or environments, and stay savvy. You can feel hopeless and frustrated a first (much like learning a new language right?) but the new muscle memory and speed payoff comes within days of flipping that mouse.
- KILL YOUR MOUSE Go on, flip it over right now and push it to the side out of convenient reach. I bet you’ll be surprised by how much you already know. Similarly, if you’re on a laptop try taping some paper over your touchpad (not forever!) to discourage you from using it out of sheer habit.
- Use cheatsheets as a reference just next to your machine. Pick 5 new ones to learn and include in your workflow every day. You can google other people’s cheatsheets, but also feel free to make your own and share it with the world or your colleagues. It’s a great way to remember a bunch of shortcuts within a particular context. Also, check out Cheatsheat for Mac that overlays all the keyboard shortcuts for your current program when you hold down the
commandbutton for a few seconds.
- Start with common workflows There are definite patterns to working as a programmer that you can already begin to tackle in isolation. Some suggestions:
- Open google, open results in multiple background tabs, jump to the relevant section of the page, switch back to code editor.
- Common code refactoring: moving lines of code up and down, removing whole lines at once, selecting portions of code word by word, commenting/uncommenting blocks of code.
- Resize and navigate between windows on multiple screens.
- Navigate, create, read, update, delete items in your file system.
- Navigate, create, read, reply/reply-all/forward, send, move, delete, archive emails.
- Pay attention to menus because they often have the keyboard shortcut right next to whatever you’re about to select with your mouse anyway.
- Try to spot patterns Sometimes keyboard shortcuts don’t make sense until you actually look at shapes your hands make and/or the physical position of the keys - as opposed to just the written command. One good example of this is
ctrl + pand
ctrl + nfor moving the cursor/caret up and down lines in Sublime, followed by
ctrl + kto delete a line. That doesn’t seem particularly intuitive when you see it written but when you get into a flow you quickly spot that
pon the keyboard so it makes sense to quickly go up and down killing any lines as you move with your 3 right-hand fingers spread across them.
- Create your own shortcuts this can range from aliases in your bash profile to prepared code snippets in your text editor. So much of programming is building tools to save other people time - do yourself a favour and build a few scripts, tools or hacks to save yourself time.
- Share the love with your colleagues and you’ll quickly pick up new tips and shortcuts.
“I wish I hadn’t learned this keyboard shortcut” - said nobody, ever.
Of course your mouse/trackpad are still appropriate for a bunch of contexts like media editing, games…wait, I can’t think of any more than that actually. You’ll be surprised how easy it is to get by without that pesky thing, lying soooo far away from the keyboard.
Not all shortcuts are created equal so tools like Alfred and Vimium exist to override and consolidate shortcuts in certain scenarios for a better experience. You’ll want to check out the tools I list below in order to have a truly pleasant time navigating with your keyboard.
Helpful Tools & Further Googling
- Alfred - most useful for being able execute a google search from any context on your mac, but also packed with loads of other features.
- Vimium - Chrome addon for mouseless web navigation.
- Spectacle - free and powerful application window management, especially useful across multiple screens.
- Cheatsheet - overlays the relevant cheatsheet on whatever you’re doing on your machine.
- Bash aliases for terminal shortcuts
- How do I make code snippets in my code editor?
- How do I create universal key commands for my OS?
Did I miss anything? Comment/feedback is always welcome.