1, themes,

As mentioned earlier, Pycharm has powerful spelling tips, including BASIC and Smart Type. In addition to this, Pycharm automatically generates some structured code and inserts pairs of curly braces and quotes.

2, automatic indentation

Type the class declaration, then press Enter:

The Pycharm cursor is automatically indent, and you can start typing function declarations here:

The automatic indentation mechanism has been activated. Here function declarations (and all nested operations) are indented by four Spaces from the left by default. The indentation rules here refer to Python’s relatively fixed code style standards, which are customized for your team (i.e. a company that needs to follow a common standard). Pycharm helps us maintain the code style according to the standards specified. Here’s how Pycharm does this. Again using this simple Code as an example, open the Settings dialog, expand the Code Style node, and open the Python page (Ctrl+Alt+S→Project Settings→Code Style →Python) :

As you can see, the indentation size specified here is 4 Spaces. Pycharm followed this rule to automatically generate code and reformatting. Of course we change the indentation rule (just like any other code rule). Suppose you want to indent 5 Spaces, meaning that all new code generated is indent 5 Spaces relative to the upper code. Visit the Smart Keys page for more detailed information.

However, the code style framework specified by Pycharm is unchangeable and a copy of Pycharm is automatically made before customization. The copy is available for us to modify:

This new configuration framework is saved in your user directory and can be shared with other team members if necessary to make it easier for the team code to be consistent. For more information on code style Settings see Project and IDE Settings.

3. Automatic completion of grammar

When you enter a parenthesis (Pycharm tries to complete the other half), Pycharm completes the system parameter self. Press Enter to move the cursor to the next input position (according to the indentation rule currently established), enter the information to be printed here, enter a parenthesis, Pycharm will automatically complete the other half of the parenthesis and place the cursor inside the parenthesis for us to enter the information to be printed:

Next, let’s test a more complex case — editing a Django template. For Django templates with very complex syntax, syntax auto-completion is crucial. OK, start typing a Django tag

  

Once you type one curly brace, Pycharm automatically completes the other one:

                     

And the cursor will stop between two %, so that we can enter the code:

                    

Similarly, Pycharm completes the other half of the {{flag.

The Smart Keys page for syntax autocompletion is displayed in the Editor Settings: Ctrl+Alt+S→IDE Settings→Editor→Smart Keys:

For example, if you want Pycharm to automatically complete parentheses, square brackets, etc., you need to check the Insert Pair BRACKET check box. To automatically complete quotation marks, check the Insert pair Quote check box. For Django templates, there is a special check box auto-insert closing}} and %} in Django Templates to choose from.

The original reference: blog.csdn.net/u013088062/…

This article is from SDK Community (www.sdk.cn/)