Because PHPStorm is the best PHP IDE exist right now IMHO. If you’re a developer who works with PHP and you haven’t heard about PHPStorm, you’re assumed to be living in the rocks. All you need is to export P圜harm Live Template configuration and import it in IntelliJ IDEA.Let’s just admit this. Once created the user template in P圜harm you can reuse it for working with Python scripts in another IDE, for example, IntelliJ IDEA. Example of sharing a template between different IDEs Thus, you have to fill in all the required fields, and press Enter at the end. Having typed the class name, press Enter, and see that the red line (frame) moves to the next field. In this case, the field for class has been filled in automatically. Note, by the way, that the variable class has been used more than once - in the class declaration, in the comment for the class constructor. The red line marks the next entry point: when you type in the class name (variable class), it will be entered in this particular location. our new live template is now in the suggestion list - you can tell it by description that we've typed just in case:Īs expected, the abbreviation expands into a stub Python class. To do that, type the template abbreviation class. Next, let's create a class declaration in it. Using a live template of your ownįirst, create a Python file ( Alt+Insert- Python file), and call it sample.py.
The new live template (or a code snippet) that expands into a stub Python class is ready. You only have to click OK In the Settings/Preferences dialog ( Ctrl+Alt+S). So in our case, the cursor will rest at the end of the new class declaration. It always stands for the position of the cursor after the template expansion and filling in all the required fields. This is because the template variable $END$ is predefined, and thus NOT EDITABLE. You have already noticed that the template variable $END$ was not suggested for editing. In the dialog Edit template variables, you see the list of all (but one!) variables:įor the variable $object$, let's define its default value object, and click OK: Side note about $END$ All, except one (wait a bit to learn why). These template variables are void yet, so let's define them first. You can easily tell them from the entire template text, since they stand out with color: The portions of a template text enclosed in $ signs are the template variables. Type the following code in the field Template text: The expansion key will be Tab, as specified by default. In the future, when the context is already defined, the link changes to Change. By now, you see that the context is not defined - so click the link Define, and select the context (in our case, this is Python). Next, let's select the context where the new template will apply. In our example, we'll type the word class in the field Abbreviation, and then enter description (which is optional, but nevertheless.). So, let's enter the template abbreviation. Defining template abbreviation and context
Second, the fields for entering the template abbreviation, description, body text, and context appear:Ģ. The new template appears in the group that holds the focus, namely user.įirst, under the group user, there is a stub live template that by now is called. The created group gets the focus.Ĭlick again. and specify its name (in our case, it is user). Open the Settings/Preferences dialog ( on the main toolbar, or Ctrl+Alt+S), expand the Editor node, and click Live TemplatesĬlick.
This tutorial has been created using P圜harm Professional version 2016.1.
To install P圜harm, follow the instructions, depending on your platform.
If you still do not have P圜harm, download it from this page. Make sure that you are working with P圜harm version 2.7 or later.
You can find all the necessary information about the types, abbreviations, variables and storage of the live templates in the section Live templates. The basics and usage of live templates are also not discussed here. Refer to the Python documentation for details. Python programming is out of scope of this tutorial. This tutorial aims to walk you through creating a live template for a Python class declaration, and using this live template. There are several pre-defined live template for Python. P圜harm comes with quite a bit of the various live templates. Tutorial: Creating and Applying Live Templates (Code Snippets) What this tutorial is about?