One of the most crucial things about building software is productivity – we want to deliver new features and make it faster and faster to do so. To achieve that, we use Continuous Integration (CI), automated build routines and tests. We use fancy Integrated Development Environments (IDEs) that automatically resolve dependencies and build projects on the fly. We basically do everything we can to make all of the auxiliary software work as efficient as we can. All of the above reside within the realm of our machines… But what about the productivity of the organic side of building software – i.e. the person who works as the developer?
In this article I’d like to concentrate on shortcuts and in general: mouseless programming. An old friend of mine – Adam – showed me the first shortcut and after that I understood how much it can improve productivity and satisfaction of work. We’ll start with the basics, then go through more advanced examples, ending at using external software and plugins. Let’s start!
I’ll be presenting shortcuts for MacBook only, but I’m sure you can find the equivalents of these for Windows as well.
The basics for MacOS
We’ve turned on our computers, and what now? We’d probably like to launch some applications. Will I go with my touchpad and move cursor the the application bar on the bottom? Nope. The most fundamental shortcut in iOS is Cmd + Space, which allows you to search for applications and run them. Following that advice we’ve opened Chrome and Skype. So, how do we now switch the focused application? Cmd + Tab (Cmd + Shift + Tab) shows all running apps. Subsequent pushing of the tab button moves the cursor, releasing the keys sets the focus. Great! What if the app doesn’t pop up? It’s probably been minimised – to retrieve it from the dock simply hold Alt key while releasing the other keys. And how do I switch focus between multiple windows of the same app? (Say multiple IntelliJ windows?) It’s simple, Cmd + Tilde does the job.
That seems basic right? Bear with me, there’s more!
Productivity boost with Spectacle
It’s been statistically proven that in Kainos there is an average of one million screens per each developer, so how do we manage all of that workspace with shortcuts to make sure our productivity is a at a decent level? Imagine I’d like to move a window from one screen to another. For that purpose I’ll use a separate app: Spectacle. It offers a set of useful shortcuts for managing the windows. Once I have the app, I’ll push Cmd + Alt + Ctrl + (left arrow/right arrow) to move the window across screens. What about resizing? Spectacle does that too: use Cmd + Alt + f to maximize the window, Cmd + alt + (left/right/up/down arrow) to resize the window against edges of the screen – very useful when you want to put two windows side by side. Check out Spectacle documentation for more shortcuts!
Some wizardry in IntelliJ
It looks like I can set up my workspace using no mouse at all, great! Let’s write some code now! IntelliJ Idea quite popular here, so that I’ll use (v. 2017). I think most of you already know them, so only briefly: Shift + Shift to lookup the symbol, Cmd + Shift + F to find a phrase in given files, Alt + F12 to focus or launch a terminal. Once in a terminal context, press Cmd + T to launch a new tab, and then do Cmd + Shift + [ or Cmd + Shift + ] to switch between the tabs.
Sometimes you’d like to locate the currently edited file within a project structure. You could click the ‘crosshair’ icon at the top of project view pane, but that introduces using the touchpad which we don’t want. I can see that the action for that icon is “Scroll from source”, but there seems to be no shortcut for that. So let’s create one! We obviously aren’t going to use the mouse to open the preferences right? Press Cmd + , to open them like a true developer. Under ‘Keymap’ section look for “Select in Project View” and set your shortcut. How do we get back from Project view to editor? That one is built in: Cmd + down arrow.
On top of the above, IntelliJ exposes the ‘Productivity guide’ which tracks your most used actions in the IDE. If you find there something extensively used and you don’t use a shortcut for that action you should consider it!
Let’s stay in a terminal realm for a while. Your project will probably be spread into multiple directories, moving around them would require a lot of ‘cd-ing’. To ease the pain, make use of Unix aliases for command line. They’re pretty easy to setup via ~/.bashrc file. For my project I defined: ‘gtf’ (Go To Frontend) that changes current working directory to a proper one. I also have the ‘pm’ alias that stands for “Pull Masters”. It triggers a custom shell script that stashes the changes on all repos in our application and pulls master branches from origin. I could post the script here but as you can read from its description the code inside is too brilliant to give it away for free. Terminal fun is done, let’s press the Alt + F12 to go back to the editor context.
Shortcutting the actions in your browser
Now we can write some code efficiently, but your code still breaks from time to time, doesn’t it? Let’s go for Google Chrome browser and look up some possible solutions!
Press Cmd + Tab to create a new tab, and Cmd + W to close it. To reopen a closed one, press Cmd + Shift + Tab. Let’s search something: open a new tab – the cursor will probably focus on the address bar where you can type your query straight away, but if it does not, Cmd + L will move the focus the address bar. Woohoo, Google gives me a list of links to click on… But hang on, clicking requires using a touchpad! We’re keyboard freaks here! Fortunately, there is a plugin to help us
Once you have installed the plugin, when you’re in the Google result page, press (Tab or Shift + Tab) to iterate the results. Nice!
Most of the time we open up multiple tabs, so how do we iterate over them? Cmd + 1,2,3,4 … 9 will jump to an equivalent tab in order. What if you’ve opened up a million tabs? Probably your computer would have died by the time you reach that number, although if it hasn’t then use Cmd + Tab (Cmd + Shift + Tab) to go to next/previous tab.
Google Chrome on steroids
Working on an IT project includes visiting the same pages many times a day, for many months. A smart person will bookmark them to increase the productivity. However, going to the bookmarked page by default requires lots of clicking though, so I went to Chrome Web Store and guess what? I found ShortKeys – a plugin for assigning key combinations to all sorts of Chrome actions. Let’s make use of it!
In my current project we’ve got five Github repositories, like: Api, Frontend, Utils. So I came up with the following shortcut patterns: Shift + O G <First letter of repo name>. What does that stand for? For example: Shift + O G F = Open Github Frontend. Shift + O G A opens the API repo and so on. For Jenkins I’ve got a similar one: Shfit + O J <First letter of repo name> .
There are a few catches with that approach though:
- Pages like Jira and Github have their own built-in keyboard shortcuts so watch out when defining your own. I’d advise you to turn off Jira shortcuts when using custom ones. You can do that in your Jira profile. For Github I have no solution.
- Unfortunately the shortcuts don’t work in a blank tab for me (tell me if you know why…).
Once you’re done, you can click Cmd + Q to quit Chrome, but that one applies to all applications in iOS.
That’s all for today
I’ve covered all of the shortcuts and tricks that I use during my daily work for better productivity. Of course, there are many more: using githooks for pre-commit actions (like triggering tests or modifying the commit message), hot-reloading plugins for applications that speed up the startup, and probably many others.
If you’re not a great fan of shortcutting your work and they seem hard to remember, just be patient – as you start to use more and more shortcuts, you should become faster and faster at learning them. And if you’ve got your own ideas for productivity, just post them below.
PS. Thanks to Adam, Arek, Kamil and Frank who participated in creating this post one way or another.