Learn the keyboard shortcuts!
As demonstrated in the previous section, PyCharm can be a very powerful IDE. It is important to note, however, that its power is constrained by the competence of the user. If used expertly, it can save huge amounts of time. When used by a beginner, it can seem unnecessarily complicated and actually has the potential to slow you down.
I can highly recommend dedicating a day or two (or three) to simply learn the ins and outs of PyCharm (or indeed another IDE). If you take the time to become an expert user, you will be much more efficient and productive in the long run!
One of the things that you can become proficient in is keyboard shortcuts. Learning as many keyboard shortcuts as possible enables you to work quicker because you don’t have to take your hands off the keyboard!
⇧⇧: opens the search window, from which you can type any file name in your project to find and open a file.
⌘E (macOS) or ^E (Windows): open a file from the list of recently opened files.
⌘/ (macOS) or ^/ (Windows): comment out/in the line of code where the cursor is, or the code that is currently highlighted.
The keyboard shortcuts described above are a very, very small snapshot of all of the shortcuts that are available to you in PyCharm. My advice is to give them a try, then practice using them until you have memorized them and they become second nature! Then start investigating and learning all the other shortcuts out there - you’ll be able to code a lot faster!
Customize your project and editor
There are a lot of different ways that you can customize PyCharm to improve your code editing experience. The best place to start is in the Preferences section. To open Preferences, go to PyCharm -> Preferences, or use the keyboard shortcut command/ctrl + ,.
Once inside Preferences, the world really is your oyster! You could go to Editor -> Font to change the font, font size and line spacing:
Another setting which people often tweak is the Color Scheme. Up until this point you might have been thinking, Why isn’t my PyCharm black? When you install PyCharm the default Color Scheme is Classic Light. I prefer to use the Darcula Color Scheme. To change this setting and see which Color Scheme you like best, go to Editor -> Color Scheme:
The Classic Light color scheme looks more like this:
Another powerful feature of PyCharm preferences is the ability to search for particular settings. I like to change the position of the visual guides in the editor, but can never remember where they belong in the settings. Instead, I simply search for ‘margin’ in the preferences search box:
From here, you can set the ‘Visual Guides’ setting to
99 . This then gives you a visual guide in your editor when your line of code reaches
99 characters in length (a common setting for Python linters/syntax checkers):
git with PyCharm
If you are already familiar with using
git to manage version control on your projects, then it is worth experimenting with integrating PyCharm with
git to manage your version control. If you aren’t familiar with
git then don’t worry - you can gloss over this section!
There are essentially three ways of managing version control with
Using the command line in the terminal.
gitin your IDE.
We are going to explore the last option, using
git as part of your IDE.
Open PyCharm CE from scratch, but instead of choosing ‘Open’ or ‘Create New Project’, choose ‘Get From Version Control’:
Now, choose the ‘GitHub’ option and enter your GitHub username and password and click on ‘Login’:
When you have successfully authenticated with GitHub, you will be presented with a list of all of the GitHub repositories that you either own or have access to. I won’t share mine for security reasons, but you can choose any of your GitHub repositories, choose a directory where you want to store the repository locally and click on ‘Clone’.
Once you have done this, PyCharm will create a new project with the code in your repository, and the repository will be available in the project tree sidebar as before:
In addition to this, a new piece of functionality will also appear in PyCharm. In the bottom left corner you should now see a
Click on the Git option to see the Git window:
git window you have all of the
git functionality that you normally have at your fingertips on the command line in terminal or using your
git client. For example, you can:
Create new branches and checkout branches.
View and interrogate the
Much, much more!
The ‘Commit’ section on the left-hand side also allows you to add files to the
git staging area and commit them as part of your normal workflow:
The full power of using
git inside PyCharm is well beyond the scope of this course, but you should explore it more to help you make an informed decision as to whether you would like to: a) use
git via the command line in terminal, b) use a
git client, or c) use
git inside PyCharm.
PyCharm can be configured and customized in lots of different ways - it is well worth exploring the Preferences section to make sure that you get the best out of your IDE.
To make sure you are using PyCharm efficiently and effectively it is worth taking some time out to learn keyboard shortcuts. Although it might slow you down slightly to begin with, it will definitely be worth it in the long run!
Congratulations - you are now a power user on PyCharm! Don’t forget to try out your new skills in using an IDE by completing the final quiz.