Using Postfix Templates
On this page:
Postfix code completion lets you transform an already typed expression to another one based on the postfix you type after a dot, the type of the expression, and its context. This transformation is performed by expanding the postfix-specific predefined template.
For example, the
.if postfix applied to an expression wraps it with an
See more at: Postfix Code Completion.
Activating and de-activating postfix templates
To activate the postfix templates functionality:
Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing for Windows and Linux or
for OS X.
Expand the Editor node, and then
click Postfix under General.
The Postfix Completion page that opens shows a list of postfixes for which PyCharm can transform expressions according to postfix-specific templates. Transformation templates are shown next to corresponding postfixes. When you select a postfix, the Description pane illustrates the corresponding transformation showing the code snippet before and after the template is expanded.
- Select the Enable postfix templates check box and choose the key to launch template expansion from the Expand template with drop-down list.
- Select the check boxes next to the postfixes for which you want PyCharm to expand the corresponding templates.
Using postfix templates
To apply a postfix template:
- Type your code followed by a dot, until a suggestion list appears, or press Ctrl+J.
- Choose the desired postfix template from the suggestion list. If necessary, choose an expression to be surrounded or replaced.
- Press the expansion key, defined in the Postfix Completion page of the editor settings.