Shortcut customizations

PyCharm also gives you the power to find, edit, and customize your own shortcuts. This means that not only can you preserve the shortcuts you have mastered in other environments, but you can also extend that set of shortcuts to perform other tasks that you couldn't before.

To see this functionality in action, move to the lower section of the current Keymap tab and inspect one of the lists that's available. For example, the following screenshot was taken when I opened the first list, Editor Actions:

Inspecting shortcuts

This list contains available actions and tasks that you can add or customize your own shortcuts for; they are ordered alphabetically, so you can look for a specific action that way. Let's consider some examples. For the Delete Line action (which will delete the whole line of code that the caret is currently at), we can see that it is associated with the shortcut  (command + delete) in macOS.

Say, for some reason, you would like to unhook this link so that every time you enter the shortcut, the current line isn't deleted. We can do this simply by right-clicking on the Delete Line action (or any action you'd like to avoid) and choosing Remove ... to unhook that shortcut.

Additionally, you can always come back to this setting and rehook the action to the shortcut, if you ever find that you'd like to keep the shortcut after all. And for that matter, you can also add your own key combination for the shortcut, including keys on the mouse.

You will also see that, in our list of actions available for shortcuts, some are not yet associated with any shortcut (for example, Move Caret Backward a Paragraph or Decrease Font Size in the preceding screenshot). By right-clicking on these options and attributing different key combinations to them using Add Keyboard Shortcut or Add Mouse Shortcut, you can also create your own shortcuts for any tasks you find convenient.

This customization is illustrated as follows:

Customizing a shortcut

On the topic of shortcuts, PyCharm offers unique functionality that maximizes your productivity in this area.

Say you are listening to a talk or watching a presentation from another developer. This developer has their PyCharm environment open to show their project and illustrate some real-time coding. As they code, they use various shortcuts that prove to be extremely convenient and make their editing much faster. Say one of the shortcuts you see them utilize moves the caret to the end of a code block and selects the line that it passes through—you can find out which shortcut they used by searching for it in the PyCharm search bar.

In the following screenshot, I typed in move caret block (separate, independent keywords—similar to googling—as opposed to an actual phrase) to narrow down the list of actions returned by PyCharm, and was able to find that the action name was technically Move Caret to Code Block End with Selection, and that the shortcut for that task (on a macOS system) is  (or option + Shift + command + ]):

Searching for shortcuts

We can see that the search bar can not only find the shortcut command for a particular given task but that it also gives us the exact name for the task. It is important to note that this search functionality is not only limited to finding shortcut actions. In fact, users can use it to find files, settings, and even classes and objects within Python code. This is why this functionality is called Search Everywhere, and it is one of the many powerful features that set PyCharm apart from other editors/IDEs.

We have seen that PyCharm allows you to find the shortcut for a particular action using its search functionality, which is widely used by programmers to find and customize their shortcuts in PyCharm. However, PyCharm also provides a reverse search functionality that most users typically do not take advantage of. Specifically, the functionality is called Find Actions by Shortcut, and is invoked when the button right next to the search bar that we have been considering is clicked, as shown in the following screenshot:

Find Actions by Shortcut button

When using this search, you can enter in a key combination, and PyCharm will tell you which, if any, action is associated with that keyboard shortcut. For example, if I wanted to find out what the combination of command + home on a macOS keymap does, I can use this search to find out that the Move Caret to Text Start action (which, as its name suggests, will move the caret to the beginning of the file currently opened in the editor) is associated with the shortcut. The following screenshot illustrates this process:

Finding a particular action using its shortcut

It is important to note that, at the time of writing, this Find Actions by Shortcut functionality is only available within the Keymap settings tab.

In this section, we have looked at various options regarding how to customize our PyCharm workspace, including themes for both the PyCharm interface and the editor within, as well as keymap and shortcut options. However, these are more general settings regarding the overall usage of PyCharm that you yourself can explore.

In the next section, we will be discussing the customizations at the project level and learn about more settings and features in PyCharm.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.90.131