How to boost development productivity with the 36 best keyboard shortcuts

This article helps software developers to boost development productivity in their IDE. It presents many keyboard shortcuts and functionalities you don’t know about yet. Although the examples are tailored to the PyCharm IDE, you will learn the methodology for discovering and adopting shortcuts for any tool. I will demonstrate how to effectively create your own cheat sheet, and why this is better than just using other people’s cheat sheets. The application of your gained knowledge to other tools and programs will make you even more productive.

Boosting digital tool productivity

This article targets developers, but I also wrote an updated blog post for a more general audience, which is also about improving your productivity for your digital tools.

Introduction

If you’re a developer you’ll probably make heavy use keyboard shortcuts in your IDE or editor. But do you really use them to your full advantage? It turns out that this is often not the case. In fact, there are many more shortcuts and tricks you are probably not aware of. Join me on a fun journey full of productivity tips that will boost your efficiency. I’ll demonstrate everything with the PyCharm IDE made by JetBrains, but the concepts apply to other IDEs, and even to other software tools.

Motivational examples

To demonstrate how keyboard shortcuts can boost your efficiency, let’s consider two simple examples. In each example, the first video (left) uses the long and complicated way, without shortcuts (or only the traditional ones, like Copy-and-paste). The second video (right) then uses the shortcut.

The first example demonstrates how to wrap a code block, await loop.sendfile(...), into a try/catch block:

Manually surround code in try/catch
Surround code in try/catch by shortcut

The second example shows how to change the order of statements, moving up the statement warnings.warn(...).

Manually move a line of code up
Move a line of code up via shortcut

As you can see, the benefits are significant. You’ll need much fewer keystrokes, and you won’t lose time switching back and forth between keyboard and mouse to make selections.

Useful efficient shortcuts by category

There are many, many functions that can be triggered by shortcuts. This section will list 36 shortcuts I personally found useful, organized by category. They are not specific to any IDE or keys. Thus, it’s still your job to find out whether these functionalities exist in your IDE, and whether they can be accessed via shortcuts. If you use PyCharm (or another JetBrains IDE), I’ve added the name PyCharm uses to describe the functionality, in parenthesis.

Warning

By opening the sections below, you’ll deny yourself the satisfaction you will feel when discovering shortcuts by yourself. I recommend you actually discover them on your own, as explained below.

If you still want to go on, or want to compare your findings with mine, click on the titles to expand the corresponding section.

In an IDE you’ll handle multiple files at the same time, which are shown in separate tabs or windows. To overcome the slow process of using the mouse to find, open, and close files, make sure you set up shortcuts for the following tasks:

  • Switch between opened files (PyCharm: Other -> Switcher)
  • Close the active file/tab, to avoid that you’re overwhelmed by too many opened tabs (Main menu -> Window -> Editor Tabs -> Close)
  • Search for any string in files – not just the current file, but all files in your project (Find in path…)
  • Search for a file, by file name (Main menu -> Navigate -> Go to File…)
  • Search for a class, by class name (Main menu -> Navigate -> Class…)
  • Jump forward or backward in this history of your cursor. For instance, this helps to quickly go back to where you were before following a code path (Main menu -> Navigate -> Back/Forward)
  • Jump backward to the cursor where you last edited code. This is sometimes more efficient than pressing the above shortcut keys multiple times. (Main menu -> Navigate -> Last edit location)
  • Move cursor left/right by sub-word of variables or function names that use camelCase or snake_case. By default, a shortcut like CTRL+Right will move the cursor by entire words. e.g. from self.|snake_case to self.snake_case| . With this shortcut, the cursor will move only to self.snake|_case. (Move Caret to Next Word in Different “CamelHumps” Mode)
  • Scroll up/down: do it with the keyboard, save your colleagues from having to listen to your noisy mouse wheel, once and for all (Scroll Down, Scroll Up. Tip: consider using Scroll down and move [cursor] if Necessary)
  • Start a new line before (or after) the current cursor line, even if your cursor is somewhere in the middle of the line. This saves you having to use the mouse, to position the cursor correctly before pressing Enter (Start New Line, Start New Line Before Current)
  • Extend or shrink currently selected text/code, with code-sensing: wherever your cursor is, by repeatedly pressing the shortcut keys, it will select more and more (or less and less) of the surrounding code of your cursor. See video below. (Extend selection, Shrink selection)
Extend the selection via shortcut

By Code navigation I refer to the ability to quickly and efficiently follow the program’s flow through the different components, in forward and backward direction. By symbols I mean concepts like functions, variables, constants, classes, or methods. PyCharm’s definition of symbols is slightly different, as it excludes classes from that list.

  • Go to symbol declaration or implementation. I previously always used CTRL+Left click to achieve this, which is slower because I have to switch between mouse and keyboard (Go to Declaration or Usages, Go to Implementation(s))
  • List all symbols in the currently opened file in a dialog. A-Z keys you press in that dialog will search in those symbols. This is a huge time saver, as it is much more efficient than scrolling and manually searching (Main menu -> Navigate -> File Structure)
  • Show inheritance hierarchy of the current class (Type hierarchy)
  • Select file of currently active tab in project hierarchy view (Select in Project View)
  • Find usage of a symbol in other places (Find Usages)
  • Open a small pop up window of the current symbol’s documentation. This is often more efficient than actually jumping to the method (see “Go to symbol declaration”), because less jumping means less brain load (Quick Documentation)
  • See the list of parameters of the function, while the cursor is in-between the brackets ( ) of the function (Parameter Info)

Sometimes writing code means having to write a lot of repetitive boiler plate. Let your IDE help you getting it done faster:

  • Code snippets: by writing just a few characters followed by pressing the Code auto-complete shortcut (Code completion -> Basic) will let you generate things like loops, a main method or other things. PyCharm refers to those as Live Templates, e.g. iter, main, or super (see Settings -> Editor -> Live Templates for more)
  • Override or implement methods from the parent class(es), which saves you having to copy/paste method signatures time and time again (Code -> Generate…)
  • Trigger the Quick fix dialog: IDEs like PyCharm will highlight when there is a problem with your code, using red and yellow light bulb symbols. Rather than clicking those with the mouse, you can trigger the quick fix dialog, which will suggest the fixes for the part of the code currently highlighted by your cursor (Show Context Actions)

When copy&paste only gets you so far, there are many small helpers you should know about:

  • Create an additional cursor at the mouse pointer location. This is useful to do the same thing in several places at once. When you type, your characters are inserted at all cursors at once (Add or Remove Caret)
  • Comment/uncomment the current line, or selected lines (Comment with Line Comment)
  • Move the current statement up/down. This intelligently moves several lines or units up down, swapping the order of statements. This is much more efficient than using cut and paste (Move Statement Up, Move Statement Down)
  • Delete current line, without having to select the current line (Delete Line)
  • Delete from cursor until the end of the current line (Delete to Line End)
  • Duplicate current line, without having to select it (Duplicate Entire Lines)
  • Create a rectangular text selection when selecting text with the mouse. When followed by pressing the left/right arrow key, you get a multi-line cursor (Create Rectangular Selection on Mouse Drag)
  • Embed (or unwrap) the current lines into structures like try/catch, if/else, or with something: context managers, as seen in the video at the beginning of this article (Unwrap/Remove…, Surround With…)
  • Reformat multi-line comments (or doc-blocks) to honor the maximum wrap-around width, which is often set to 120 characters (Fill paragraph)
  • Rename the symbol under the cursor – the symbol does not even have to be selected: (Rename…)
  • Remove imports (Python) that are not actually used by the code (Optimize imports)
  • Reformat the code, applying the currently configured code style (Reformat code)
  • Show a menu that offers various other refactorings (Refactor this…)

Surely, you are familiar with copying, cutting and pasting text from and to the clipboard. But there’s more!

  • Copy to clipboard without formatting. This is useful if the editor where you paste code into does either not support stripping the formatting (like color and font), or requires manual labor to remove it afterwards. This is a life saver when documenting code snippets to word processors like LibreOffice Writer, where the “Paste special” command never seems to work properly (Copy as Plain Text)
  • Paste from the history of copied content. IDEs like PyCharm keep a history of the text snippets copied to the clipboard from within the IDE. Triggering this special “paste from history” will open a pop-up where you can select which text to paste. This saves valuable time if you want to transfer several sections from one file to another, as you won’t need to switch back and forth between those files (Paste from History…)
  • Add a selection to an existing selection, e.g. selecting the first, third, and fifth line of a file (Add or Remove Caret)

Three general tips for building shortcuts

  1. The shortcuts presented above are just a glimpse of what’s possible. You really need to go through your IDE’s keyboard mappings dialog and investigate all the available functions. I would never have discovered tricks like “Copy as plain text” or “Embed into try/catch” otherwise. Sure, the list has hundreds of options, which is daunting at first. You’ll have to spend 1-2 hours to make it through. However, once you have discovered the first few shortcuts, you’ll become really motivated and time will fly by – I promise! You’ll feel like a gold digger who keeps finding nuggets.
  2. Find ways to synchronize and remotely save your keyboard mappings, e.g. to a file. You put a lot of effort into customizing those shortcuts, so you better not lose this work by accident. Also, if you work on multiple machines, you’ll want the shortcuts to be the same everywhere. The mechanisms vary for each program. The PyCharm IDE, for instance, has several synchronization options. However, beware of bugs in that functionality. The JetBrains products are great in all respects, but they messed up settings synchronization, and haven’t fixed bugs in a long time. I recommend you use the synchronization via a Git repository, as this will allow you to revert data loss caused by the IDE.
  3. Assign sensible keys when creating new shortcuts. For instance, use the first letter of the keyword that comes to your mind when you think about the functionality – e.g. P to show the list of parameters of a function. Another trick is to augment existing shortcuts you already know by adding modifier keys (like ALT, Shift, etc.). For instance, if CTRL+C is copy selection, then copy selection as plain text should be similar, e.g. CTRL+ALT+C.

How to adopt keyboard shortcuts

The problem

There are way too many shortcuts to remember. Even though you may remember that there is a shortcut for the functionality you want to use, you need an efficient way to look it up. If looking it up took you longer than just doing things manually, you wouldn’t have gained anything.

The solution

My suggestion is that you create your own cheat. I’m using the following approach:

Create cheat sheet document

Create a new, empty cheat sheet with your favorite word processor or spreadsheet editor. Go through all available shortcuts in your IDE. Write down an unstructured list of all short cuts, in random order. You only need two columns, one for the shortcut’s keys combination, one for the description of the functionality. Use your own words to describe it, using keywords you’d use when searching for it. If in doubt, use several keywords.

Optional: group shortcuts by category

When you group your unordered shortcuts by category, you’ll have a higher chance of remembering which shortcuts exist. It will also improve the readability in case you study your cheat sheet and it may help you think of even more commands to find keyboard shortcuts for.

Facilitate access to your cheat sheet

Make your cheat sheet as easily accessible as possible, e.g. by creating a link in your task bar (Windows) or dock (macOS). You can also create a keyboard shortcut that opens the cheat sheet.

Whenever you work in your IDE and need to look up a shortcut, open the cheat sheet and use the editor’s search functionality to find the shortcut. This is much more efficient than manually looking through all cheat sheet entries, and it also beats using the IDE’s integrated shortcut search, which wouldn’t find things for your keywords.

You’ll realize that your cheat sheet is a living document. Over time, you’ll be updating the descriptions of the functionality, optimizing the keywords you use when searching for them. You’ll also update the keys of the shortcuts occasionally, e.g. if a combo is too hard to press, or if you found more logical key combinations.

What I just described is the on-demand adoption of shortcuts. You can also adopt them via deliberate practice. My approach is to print out my cheat sheet, but hiding the key combination column. With the IDE ready, I randomly select a shortcut with my fingers and try to execute the command as fast as possible.

About those pretty cheat sheets from the Internet

You are probably familiar with cheat sheets other people put on the Internet. They use pretty colors and fonts, neatly laying everything out on a single page. Inspired by those, I actually created such a cheat sheet myself, shown in the image below. However, I found that such pretty single-page cheat sheets are a bad idea, and I will never make or download such cheat sheets ever again. Here are the three reasons, why:

  1. They are hard to edit
    • They are often in PDF, which is not meant for editing!
    • The layout will break immediately once you add or remove entries, or change the wording!
  2. They are not meant for you
    • The items on a cheat sheet are those that the author found helpful for herself. Your interests might be entirely different from those of the author!
    • The wording that describes the shortcut’s functionality might not work for you. You might not find things easily!
  3. No reflection or motivation to use them
    • No matter what kind of cheat sheet this is, it’s not just about the result, but also about the work that goes into it. It’s like reading an entire book vs. reading just a three-page summary: you’ll know much more after reading the former, having reflected the content.
    • You’re much more likely to remember and use shortcuts (and the related functionality) that you discovered yourself. You are connected to those discoveries emotionally. You will be motivated to use them, as this is the pay-off for the work you did before.

Now, my cheat sheets are just regular spreadsheets, where I can move rows and columns around quickly and find things efficiently using the search function. Tip: if you want to do a fuzzy search, find out whether your editor supports “wildcard search”. For instance, Microsoft Word or LibreOffice editors support wildcards in the “Find and replace” dialog. Consequently, a search for “rename*method” (using * instead of space) will find entries such as “Rename variable/method”.

Beyond shortcuts: Learn your tools

Another tip to boost your productivity is to examine your IDE more closely. It probably has a lot of features you might not need a shortcut for, but still want to access from time to time. Go through the menu structures and dialogs, study the manual, or search the Internet for productivity tips related to your IDE.

Additionally, chances are high that your IDE is extensible by add-ons / plug-ins. So make sure to check out which popular plug-ins exist and how they can make your life easier.

For PyCharm, I found many useful features, such as the integrated HTTP REST client, or the ability to create and update copyright notices, which is very useful for open source projects whose licenses require such notices in every file. I also found great plugins such as a PlantUML integration, mind mapping, grammar checking or JSON parsing. There is even a plug-in that reminds you to use shortcuts.

Conclusion

The key to boosting your software development productivity is to explore the features of your IDE. Assign and adopt shortcuts to get the many little things done faster than ever before.

Most importantly, this process can be applied to any tool or program you use regularly, e.g. a word processor, video editing software, browser-based software (e.g. WordPress), the Linux shell, or those command-line tools like Git or Docker which you might use. In the best case, you can even change shortcuts so that the same key combinations will trigger a specific functionality in every software.

Leave a Comment