DEV Community

Cover image for Know Your Tools: PyCharm
Nadezhda Yuzhakova
Nadezhda Yuzhakova

Posted on • Edited on

Know Your Tools: PyCharm

Throughout my career as a Product Manager, I’ve developed key principles. One of them is "Know Your Tools." This concept is inspired by The Pragmatic Programmer. “Tools amplify your talent. The better your tools, and the better you know how to use them, the more productive you can be”. For me, this means taking the time to thoroughly learn the tools you use every day.

Two years ago, I started learning Python (read more about Technical Skills for Product Manager). I soon realized the depth of the rabbit hole, and solving problems in Python quickly became my hobby. For my coding journey, I have used PyCharm and invested my time in mastering it. In this article, I invite you to discover simple yet powerful JetBrains IDE features that are accessible at any proficiency level and inspire you to explore further.

Learning Tools

First of all, I highly recommend the onboarding tour to everyone using JetBrains' IntelliJ-based IDEs (Help -> Learn IDE Features). It's an absolute masterpiece and a truly enjoyable process. In my opinion, it sets the standard for what a learning guide should be.
However, people may hesitate to follow learning guides, finding it challenging to remember new features, which may not match their proficiency level or might simply be boring. That's why I prefer focusing on 4-6 features, mastering them, and then progressing to the next set.

Search Everywhere

Press ⇧ (macOS) / Shift (Windows/Linux) twice to open Search Everywhere. Suppose you are looking for the file password_generation.py. Type “pg” as the initial letters of these words and see the results.
Search Everywhere Feature Demonstration
You can type any words or letters you think might be part of your file, and it will work. This feature is colloquially referred to as Fuzzy Search. The same technology is available in the Find Action ⇧⌘A (macOS) / Ctrl+Shift+A (Windows/Linux).

Restore Removed Code

If you removed some code fragments and made several valuable changes, the usual “undo” is not a suitable solution. But restoring code from history works perfectly. Right-click anywhere in the editor to open the context menu, and go to Local History -> Show History. Find the code fragment you need to restore and click the button >>
Code Fragments in the Local History Window

Code Selection

In addition to the usual ⇧+Arrows (macOS) / Shift+Arrows (Windows/Linux), you can try the ⌥+Arrows (macOS) / Ctrl+Shift+Arrow (Windows/Linux) combination. Press ⌥+Up Arrow (macOS) / Ctrl+Shift+Up Arrow (Windows/Linux) to select the word, once again to select the whole string, and once again to include quotes in the selection.
Code Selection Example
Press ⌥+Down Arrow (macOS) / Ctrl+Shift+Down Arrow (Windows/Linux) to shrink the selection. If you move the caret to the beginning of code blocks, this action will select this segment.

Move Code

Press ⌘⇧+Up/Down Arrows (macOS) / Shift+Alt+Up/Down Arrows (Windows/Linux) to move code fragments. For moving methods, the caret should be at the header of the method. Another shortcut ⌘+Del (macOS) / Ctrl+Y (Windows/Linux) is useful to remove lines.

Syntax Quick-Fixes

JetBrains IDEs are a perfectionist's dream… and nightmare. They won't let you sleep until every warning is fixed. Thankfully, you can simply press ⌥+Return (macOS) / Alt+Enter (Windows/Linux) to reformat your file and turn imperfect code into polished perfection.
Example of Syntax Quick-Fixes
Another useful feature is removing redundant parameters from all the code. It’s really beautiful how this feature optimizes your code if needed.
Quick Remove of Redundant Parameter
You also can remove redundant imports.
Optimize Imports

Automatic F-string Completion

If you have a simple Python string but want to convert it to an f-string, just start typing {whatever… select the suggested parameter, and the string will be transformed into an f-string automatically.

Rename Refactoring

If you need to rename some variables in the files, the Rename Refactoring feature is your time saver. Press ⇧F6 (macOS) / Shift+F6 (Windows/Linux) to rename.
Rename Feature
All usages of this parameter will be renamed automatically.
Code after Rename Refactoring
In difficult cases with many usages, you will be advised to choose files for refactoring.

Explore Further

I use PyCharm Community Edition for my coding practice. However, PyCharm Professional offers support for many Python frameworks, has integrated DB tools, an HTTP client, and more. So, if you are working on a complex web-based commercial project, PyCharm Professional could be a more suitable tool. The AI Assistant also looks very intriguing and is next on my list to explore.

Conclusion

We can't harness the full power of our brains, but we can maximize our use of JetBrains tools. Don't settle for a basic level of proficiency. Mastering tools can significantly boost your productivity and inspire you to bring new features into the products you create.

Top comments (0)