Book Image

Mastering PyCharm

By : Nafiul Islam
Book Image

Mastering PyCharm

By: Nafiul Islam

Overview of this book

Table of Contents (18 chapters)
Mastering PyCharm
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The basics


The first time you install PyCharm, the theme will default to IntelliJ. But, if you prefer something darker, I suggest you use Darcula. I personally prefer a darker IDE, so I go with a custom version of Darcula that's tailored to my tastes.

However, let's start with the default UI and see how we can make PyCharm look a little better.

The first change – fonts

The first thing that hit me when I opened up PyCharm was the hideous font set by default to be Courier New. Let's change this:

With the color scheme set to Default, you will need to save your new color scheme with a different name before you can go about making any changes to the scheme. You can just click on Save As... and then simply enter the name of your scheme in the popup. After doing so, you are free to make any changes you wish.

The Show only monospaced fonts option is enabled by default, but you can change it to include other fonts such as Arial or Times New Roman as well. Also the choice of a secondary font is important when you're trying to import your settings to another computer that does not have your desired font.

A typical example would be Consolas; it's only available on Windows machines, so when you try to import your font settings to Ubuntu or Mac, you likely get the default monospaced font. I usually set my default font to Consolas and my secondary font to Ubuntu Mono since it's free and can be made available on all the machines.

Now that the font business is taken care of, let's get down to a couple of other features. We will revisit this part of PyCharm pretty soon.

The layout

The default PyCharm layout is quite minimal. With reference to the preceding screenshot, you get an editor in [1], and the list of your directories and files in [2]. Actually, [2] is a sidebar, so if you click on [3], you get a totally different sidebar popping up.

You can show/hide it using Alt + number indicated by the underline. So, in this case, if you were to press Alt + 7, the panel indicated by [3] (Structure) would show up. Once you're familiar with the layout, you can hide all the panel buttons by clicking on [4].

The minimalist

If you'd like to focus completely on the code, you ideally want a minimalistic layout without all the extra tools taking up your screen. Let's see how PyCharm can help us with this.

So far, we can hide panels; now let's get rid of all the other distractions as well. The area highlighted with the arrow in the preceding screenshot is called the navigation bar; if you'd like to get rid of it, you can deselect the Navigation Bar option in the View option menu.

Note that with the Navigation Bar option, you also lose the Run, Debug, Coverage, and Search Anywhere buttons; but don't worry, there are plenty of shortcuts available so that you can do everything you want from your keyboard.

You can make the navigation bar appear as a popup instead of being a permanent bar by pressing Alt + Home (if this is not your shortcut, search for navigation bar in the Keymap):

As for the Debug and other buttons that we got rid of, you can always get them through Find Action, Ctrl + Shift + A.

Search Everywhere searches files, actions, classes, objects, and pretty much everything using double Shift (pressing Shift twice in quick succession):

PyCharm can also go to full screen mode (it even gives you a nice helpful clock in the top right):

I never use this mode because with my start menu minimized, with no navigation bar, and a collapsible Project sidebar, I have plenty of screen space to get the job done.

Another tool that I really appreciate is Switcher, which can be invoked with Ctrl + Tab. It appears as a floating window:

You can quickly navigate through your open files on the right-hand side of the window, and on the left-hand side you have some commonly used tools. You can navigate by pressing Tab again, and this will proceed through the list. You can also use the arrow keys. However, note that you will need to keep the Ctrl key pressed down as long as you're using Switcher.

You can quickly get to them by pressing the key underlined. In this case, you can quickly get to Terminal through first pressing Ctrl + Tab to bring up Switcher; if, while holding down the Ctrl key, you press 4, (in the preceding screenshot, Terminal is 4, but you might get a different number), you can open up Terminal.

You can close anything, that is, a tool panel or an editor tab using Ctrl + F4.