In this section of our tutorial we are going to discuss some of the tips and tricks that helps us to navigate through PyCharm. We will also discuss some of the important shortcuts in PyCharm which can save our time while working with our code. Thus, without further delay let us jump into our discussion.
❖ How To Edit An Existing Project In PyCharm?
While working on large projects, you have to deal with pre-existing code. Let us have a look at how we can use a pre-existing project and modify it. Please follow the steps given below:
Step 1: Click on File → Open on the main menu. (In case you are on the Welcome Screen, Click on Open.)
Step 2: Locate the folder which contains the project on your computer and open it.
Note: If the project already has a virtual environment then it will be used automatically and PyCharm will make it the project interpreter. To use a different environment follow the steps given below:
- Open Preferences
- Press Cmd +, if you are using Mac.
- Press Ctrl+Alt+S if you are using Windows.
- Find the Project: Project_Name
- Choose Interpreter
- From the drop-down list select
- The remaining steps are the same as creating a new project.
❖ Shortcuts And Navigation In PyCharm
While dealing with long programs or large projects it might become extremely difficult to search/navigate variables and functions throughout the code. But PyCharm comes to our rescue and reduces the load by providing some amazing shortcuts and quick ways to navigate across various parts of our program/project.
A keymap specifies key bindings for various key sequences that perform a certain function. For example ctrl + c is a keymap for copying text (in Windows). To show the most important commands used inside the interpreter, PyCharm includes various predefined Keymaps/Keyboard Shortcuts and also allows you to create your customized them. These shortcuts can be really helpful and save you a lot of time while programming.
To view these shortcuts, open the Settings/Preferences dialog by pressig Ctrl+Alt+S on your keyboard and select Keymap.
Another way of finding the list of keymaps available is as follows:
- Click on Help on the menu bar.
- Then click on Keymap Reference from the drop-down menu.
This opens up an entire list of predefined Keymaps/shortcuts available in PyCharm in PDF format as shown below.
Given below are the links to keymap references available in PyCharm. Please go ahead and open them up and go through the list of shortcuts available in PyCharm.
Note: If your keymap stopped working after an update, it is likely that the keymap is not available by default in the new version of PyCharm. Find this keymap as a plugin and install it as a plugin.
For a more details, please refer official documentation.
✨ Pycharm Omni And Macro
◈ Omni refers to the ability to move from one place to another within the project in PyCharm. The Omni functionality is placed under the Navigate option of the menu bar. Let us have a quick look at how we can use it.
1. Navigate between Classes
- For Mac: Cmd + O
- For Windows/Linux: Ctrl + N
- Click on Navigate.
- Select Class from the drop-down menu.
3. Search and click on the class in the search box that appears on the screen as shown below.
2. Back and Forward
This option helps us to go backward and forward through the history of navigation after we jumped around.
- For Mac:
- Back: Cmd+[
- Forward: Cmd+]
- For Windows/Linux:
- Back: Ctrl+Alt+Left Arrow Key
- Forward: Ctrl+Alt+Right Arrow Key
You can also perform these actions from the Navigate menu.
◈ Macros help us to define a convenient way to automate repetitive procedures that we often do while coding. We can
- record, edit, and playback macros,
- assign a shortcut to macros,
- share macros.
Note: Temporary macros are allowed without a name whereas permanent macros must have a name.
Let us have a look at an example to understand the usage of Macros:
- Open Edit menu ➠ Macros ➠ click Start Macro Recording.
- Perform necessary actions that you want to be recorded.
- Select Edit ➠ Macros ➠ Stop Macro Recording or Press
- In the Enter Macro Name dialog, specify the name for the new macro and click OK.
- Go to Edit menu ➠ Macros ➠ click on Playback Last Macro
❖ Integrating Version Control In PyCharm
Version control is one of the essential parts of software configuration management and responsible for managing changes to computer programs, documents, large websites, or other collections of information. Thus it can be considered as one of the major components of development which makes it essential for an IDE to support VCS. PyCharm allows us to implement version control by integrating numerous Version Control systems that include Git, Mercurial, Perforce, and Subversion.
Let us have a look at an example where we will be integrating Git as the Version Control system.
✨ Enable VCS Integration
VCS ➠ VCS Operations Popup…
✨ VCS Configuration
- Press Alt + ` or in the main menu click on VCS ➠ VCS Operations Popup…
- Select Enable Version Control Integration.
- From the drop-down list select, Git ➠ click on OK.
Now the VCS Operations Popup… will have different options as shown in the figure below:
Let us have a quick look at a git commit after integrating Git successfully in PyCharm. (This is a part of git and not within the scope of this tutorial. But it is always good to go the extra mile and examples are the best way to do so.)
◈ To perform a commit: Go to VCS → VCS Operations Popup… → Commit… or press Cmd + k on Mac or Ctrl + K
Follow the illustration given below for a better visualization of the entire process.
❖ Plugins and External Tools in PyCharm
A plugin helps us to add specific features to an existing program thereby extending the core functionality of PyCharm. They provide us numerous features, some of which have been mentioned below:
- Plugins help to integrate version control systems, application servers, and other tools.
- Add coding assistance support for various languages and frameworks.
- Boost productivity with shortcut hints, live previews, File Watchers, and so on.
To find and add a plugin:
- Go to Settings/Preferences dialog Ctrl + Alt + S select Plugins.
- Find the plugin in the Marketplace and click Install.
- By default, there are number of bundled plugins within PyCharm. These bundled plugins can be disabled, but cannot be removed. Additional plugins from the plugin repository or from a local archive file (ZIP or JAR).
- If a plugin depends on some other plugin, PyCharm will notify you about the dependencies.
This was the last article within the fundamentals of PyCharm series. I hope you enjoyed it!
Where to Go From Here?
Enough theory. Let’s get some practice!
Coders get paid six figures and more because they can solve problems more effectively using machine intelligence and automation.
To become more successful in coding, solve more real problems for real people. That’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?
You build high-value coding skills by working on practical coding projects!
Do you want to stop learning with toy projects and focus on practical code projects that earn you money and solve real problems for people?
🚀 If your answer is YES!, consider becoming a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.
If you just want to learn about the freelancing opportunity, feel free to watch my free webinar “How to Build Your High-Income Skill Python” and learn how I grew my coding business online and how you can, too—from the comfort of your own home.