Generate custom code constructs using live templates
PyCharm provides a multitude of predefined live templates for many common code constructs. You can also define custom templates to cover use cases specific to your workflow.
Place the caret at the place where you want the template to expand.
Type the template abbreviation and press the invocation key (usually Tab by default). Alternatively, on the Code menu, click Insert Live Template Ctrl0J to open the suggestion list and select the necessary template.
If the selected template requires user input, the corresponding field is highlighted. Type the necessary value and press Enter or Tab to complete input and move to the next input field. After completing all input fields, the caret moves to the end of the construct (or to the
$END$
marker if the marker is defined in the template code), and the editor returns to the regular mode of operation.
You can also wrap fragments of code using surround templates.
Select a piece of code to be surrounded.
On the Code menu, click Surround With CtrlAlt0J to open the suggestion list and select the necessary template.
Thanks for your feedback!