Table of Contents
tldr: If you don't have the time to read the entire post, just read Productivity Guide, because I assume that you want better productivity as your primary goal.
PyCharm is a very powerful IDE, and has a multitude of features that keep growing at a large pace. PyCharm is essentially, a plugin built on top of the IntelliJ platform, Jetbrains' main IDE. Because PyCharm borrows from a whole host of features available from IntelliJ, its easy to get lost. [1]
This post shows you some of the best features that PyCharm has to offer, and how to use those features properly. I assume that you've installed plugins and know your way around the IDE. The table of contents should give you an idea of what is covered in this post.
Productivity Guide
You might not know this, but PyCharm tracks what features you use, and tells you how productive you are being in your productivity guide:
The productivity guide gives you detailed descriptions of what features can help you code faster. You can see below that although I don't use all the features, I do use some quite a lot:
Starting Out
PyCharm touts its project creation wizard a lot, and for Windows users is a godsend because you can easily create a project and associate a virtualenv with it. However for *nix users, the best option is to start PyCharm from the command line, and you can do this by creating a command line launcher:
There is one thing that you need to know about starting from the command line is that PyCharm uses the interpreter that the python
command is linked to. So for example, if your python
command in the shell links to /usr/bin/python
, then that interpreter will become the interpreter for your new project. However, if you want to have the interpreter as a virtualenv, you have to create the virtualenv, activate it and then use the command line launcher to initialize your project. If we do the following:
$ mkdir SimpleProjectDir
$ cd SimpleProjectDir
$ charm .
It would create a PyCharm project in SimpleProjectDir
and use the default interpreter in the shell like so:
We can see that it is the same python
that was linked to in our shell:
$ which python
/usr/local/bin/python
However, if we were to create a virtualenv beforehand and then create a project using the command line launcher, we would get the virtualenv as the interpreter instead:
$ mkdir SimpleProjectDir
$ cd SimpleProjectDir
$ virtualenv .venv
New python executable in .venv/bin/python2.7
Also creating executable in .venv/bin/python
Installing setuptools, pip...done.
$ source .venv/bin/activate
(.venv)$ charm .
In simple terms, whatever python
points to in the shell at the time of using the command line launcher, PyCharm will adopt that interpreter as the project interpreter.
Keyboard Shortcuts
Keymap
PyCharm allows you to see all your keyboard shortcuts using the Keymap. Keymap has two key features which aid in development. One being the ability to find keyboard shortcuts based on what they're called:
But it also allows you to find shortcuts based on the keys themselves, so that you can talk other people about them:
So, whenever I talk about an action like "Find Action" or "Search Anywhere", just search it up on your keymap to see the corresponding keyboard shortcut.
Find Action
The best way to learn Keyboard shortcuts is to use Find Action. [2] Every time you use an action using find action, the keyboard shortcut is also denoted on the right:
Whatever you find yourself using over and over again through Find Action, just commit it to memory and you'll be saving yourself some time.
Useful Shortcuts
Use the Keymap to find what shortcuts these commands refer to: [3]
- Find Action
- Search Everywhere
- Find
- Structure
- Add Selection for Next Occurrence
- Switcher
- Check In Project
- Syntax Aware Selection
- New
The first two features are must use shortcuts, and will aid you in learning more shortcuts as you see fit. The others are shortcuts I use regularly, and find helpful.
Up Next
In the next part, I will cover editing in PyCharm, with special respect to taking control of its powerful code completion feature-set.