One, foreword
Pycharm is undoubtedly an IDE with a powerful keyboard shortcut system, which means that everything you do in Pycharm, such as opening a file, switching the editing area, etc., can be done with a keyboard shortcut. Using shortcuts not only speeds things up, but also makes them look cool. However, if you are used to using some shortcut schemes, your fingers will become accustomed to them and it will be difficult to change.
If you are extremely demanding in terms of shortcuts, you can customize Pycharm Settings according to your habits to make them work for you. For more information about basic keyboard shortcuts, see Configuring Keyboard Shortcuts or Keymap.
Of course, if you have previous experience with other software, you can also choose a configuration scheme for other software shortcuts included in PyCharm
This step is as simple as clicking the Settings button in the main toolbar and Keymap in the Settings dialog box.
2. Pycharm
1. Editing
Ctrl + Space Basic code complete (class, method, property) Ctrl + Alt + Space Quickly import any class Ctrl + Shift + Enter statement complete Ctrl + P parameter information (call parameters in method) Ctrl + Q Quick view of F1 external document Shift + F1 external document, Go to the web document home page Ctrl + Shift + Z --> Redo Ctrl + Mouse Introduction/Enter code definition Ctrl + F1 Display error description or warning messages Alt + Insert Automatically generate code Ctrl + O re-method Ctrl + Alt + T Select Ctrl + / Line comment/Uncomment Line Comment Ctrl + Shift + / block comment Ctrl + W Select the added code block Ctrl + Shift + W Return to the previous state Ctrl + Shift +]/[ Select code block End, Start Alt + Enter Quick correction Ctrl + Alt + L code formatting Ctrl + Alt + O Optimization Import Ctrl + Alt + I Auto indent Tab/Shift + Tab indent, no indent current line Ctrl+X/Shift+Delete Cut the current line or selected code block to the Clipboard Ctrl+C/Ctrl+Insert Copy the current line or selected code block to the Clipboard Ctrl+V/Shift+Insert Paste Ctrl+ Shift+ V from the clipboard Paste Ctrl + D from the nearest buffer copy the selected area or line Ctrl + Y Delete the selected line Ctrl + Shift + J Add Smart Line Ctrl + Enter Smart Line Cut Shift + Enter Another line Ctrl + Shift + U Toggle between selected areas or code blocks Ctrl + Delete Delete to end of character Ctrl + Backspace Delete to start of character Ctrl + Numpad+/- Expand/collapse code block (current position: Functions, comments, etc.) Ctrl + Shift + Numpad+/- Expand/collapse all code blocks Ctrl + F4 close running tabsCopy the code
2. Search/Replace
F3 Next Shift + F3 Previous Ctrl + R replace Ctrl + Shift + F or Shift 2 times in a row If you look for a function name string to see how the function was used previously} Ctrl + Shift + R global substitutionCopy the code
3. Running
Alt + Shift + F10 Run mode Configuration Alt + Shift + F9 Debug mode Configuration Shift + F10 Run Shift + F9 Debug Ctrl + Shift + F10 Run editor configuration Ctrl + Alt + R Run the manage.py taskCopy the code
4. Debugging
F8 Skip F7 enter Shift + F8 Exit Alt + F9 Run cursor Alt + F8 verify expression Ctrl + Alt + F8 Quick verify expression F9 Restore program Ctrl + F8 Breakpoint switch Ctrl + Shift + F8 Check the breakpointCopy the code
5. Navigation
Ctrl + N jump to class Ctrl + Shift + N jump to symbol Alt + Right/Left jump to next, previous edit TAB F12 Return to previous Tools window Esc Return to edit window from Tools window Shift + Esc Ctrl + Shift + F4 Close active TAB Ctrl + G View current line number, character number Ctrl + E Current file pop-up, Open the list of most recently used files Ctrl+Alt+Left/Right Back and Forward Ctrl+Shift+Backspace Navigate to the most recently edited area Alt+ F1 Find the current file or logo Ctrl+B/Ctrl+Click Jump to declare Ctrl+ Alt + B jump to implementation Ctrl + Shift + I View quick definitions Ctrl + Shift + B jump to type declaration Ctrl + U jump to parent method, parent class Alt + Up/Down Jump to previous and next method Ctrl + ]/[Jump to code block end, start Ctrl + F12 pop up file structure Ctrl + H Type hierarchy Ctrl + Shift + H Method hierarchy Ctrl + Alt + H call hierarchy F2 / Shift + F2 Next, previous highlighted error F11 Bookmark Switch Ctrl + Shift + F11 Bookmark mnemonic switch Ctrl + #[0-9] Jump to the marked bookmark Shift + F11 Display bookmarksCopy the code
6. Usage Search
Alt + F7/Ctrl + F7 Query usage in a file Ctrl + Shift + F7 Highlight usage in a file Ctrl + Alt + F7 display usageCopy the code
7. Refactoring
F5 Copy F6 Cut Alt + Delete Safely Delete Shift + F6 Rename Ctrl + F6 Change signature Ctrl + Alt + N Inline Ctrl + Alt + M Extract method Ctrl + Alt + V Extract attribute Ctrl + Alt + F extract fields Ctrl + Alt + C extract constants Ctrl + Alt + P extract parametersCopy the code
8. Control VCS/Local History
Ctrl + K Submit project Ctrl + T Update project Alt + Shift + C View recent changes Alt + BackQuote(')VCS pop-up quicklyCopy the code
9. Live Templates
Ctrl + Alt +J Insert template with Template Ctrl +JCopy the code
10. General
Alt + #[0-9] Open the corresponding tool window Ctrl + Alt + Y Sync Ctrl + Shift + F12 Maximize edit switch Alt + Shift + F Add to favorite Alt + Shift + I check the current file according to the configuration Ctrl + Ctrl + Alt + S opens the Settings page Ctrl + Shift + A Finds all the actions in the editor Ctrl + Tab toggles between WindowsCopy the code
This article from: www.cnblogs.com/Pythonzrq/p…
Three, ten practical skills
1. Automatically generate imports
If you are writing code and want to import a package, you only remember the package name but forget which py file it is in, you can import it automatically through Pycharm. When you write a package name, PyCharm prompts you to import it or not, which will generate the import in the correct way according to your project style.
(Animation takes 8 seconds to load, wait patiently)
2. Move classes and methods in batches
When you’re refactoring code and need to move some classes or functions to another file, you’re a little cute if you’re cutting and pasting classes into other files. Pycharm provides a move function that allows you to move classes and methods in batches, including class dependencies.
(Animation takes 8 seconds to load, wait patiently)
3. Quickly jump to the recently edited file
If you have a lot of project files, what do you do if you want to jump between them? Use the Recent File action to quickly jump between files you are working on. You get a low-interrupt pop-up window that is keyboard-friendly and lets you jump between the files you are viewing. The shortcut keys are Ctrl-E on Windows/Linux and cmd-e on the Mac. Press it twice and you’ll be surprised!
(Animation takes 8 seconds to load, wait patiently)
4. Quickly return to the last operation
For example, if you want to quickly go back to the source code of a library, you can use the keyboard shortcuts Ctrl-Alt-left/Right Win/Linux, option-cmd-left/Right macOS, in addition to clicking back with the mouse.
(Animation takes 8 seconds to load, wait patiently)
5. Quickly add a new line
We often add a line of code in the middle of another line. Maybe we are fixing something and want to move on to the next line. It usually takes two steps, go to the end of the line, press Enter to add a line on top, or go to the beginning of the line, press Enter to leave space on top, press up to go to that new empty line, maybe Tab a few times to indent it correctly, Instead, use the Start New Line function (shift-Enter Win/Linux/macOS).
Place the cursor anywhere in the current line (just finished editing), and then use the correct indentation to get the empty next line. For the above lines, use “Start a new line before current location” (Ctrl-Alt-Enter Win/Linux, option-cmd-Enter macOS.) , you get a new line, indented based on language and context.
(Animation takes 8 seconds to load, wait patiently)
6. Use the keyboard for quick code selection
In coding, we select code and operate on it. For example, move it to another line, change its indentation, and so on. You can use the mouse to select. Or, use a keyboard. For example, to move the cursor one word forward or backward by moving the caret to the previous word with the selection (shift-Ctrl-left/right Win/Linux, option-shift-left/right macOS), what about selecting three words? Do three times? .
In Python code, you often want to expand the selection from where the cursor is: symbols, substatements, complete statements, lines, blocks, and so on. Extending the selection range (Ctrl-W or Shift-Ctrl-W Win/Linux, option-Up/Down macOS) is ideal. It works semantically. Keep pressing it until you get the desired selection.
(Animation takes 8 seconds to load, wait patiently)
7. Use the keyboard to move code blocks up/down
We want to process the code quickly in the editor. Using cut-and-paste is a quick way to do it, but there’s a better way to not delete code from a file for a while. Make the selection (without using the mouse), then use (shift-Alt-up/Down Win/Linux, option-shift-up/Down macOS) to move the selection to the target line. In the view, the selection keeps dragging.
(Animation takes 8 seconds to load, wait patiently)
8. Rename the file and its references
You give a variable a name. But then you want to change it to another name. You don’t want to bother to find all the places to use it. Search and replace may uncover a large number of false positives. You can rename (shift-Ctrl-Alt-t, Win/Linux, Ctrl-t, macOS) to change the file name and name. Most importantly, if you change your mind, undo restores it as an editor transaction.
(Animation takes 8 seconds to load, wait patiently)
9. Quick review of function documentation
We often encounter inconclusive code. Someone else’s code. Even our code. Sometimes we just want the parameters of the function. We want to know positional arguments and keyword arguments. Or the type of the parameter. Or its default value. PyCharm has a variety of capabilities to show you documentation about symbols.
First, quick Documentation (Ctrl-P Win/Linux, F1 macOS) brings a non-intrusive inline pop-up window that displays all the information, with a hyperlink where you can navigate to the definition.
Click again and the pop-up becomes a tool window that updates for each symbol you log in. Always there, always helping… Until you want to hide it, just like any other IDE tool window.
(Animation takes 8 seconds to load, wait patiently)
10. Delete unused packages in batches
Instead of manually deleting unreferenced packages one by one, you can use the Alt/CtrL-0 shortcut to Optimize Imports. Control-option-the letters O macOS, Pycharm will help you remove unused packages in batches.
Animation takes 8 seconds to load, wait patiently