Code snippets in PhpStorm

PhpstormCode SnippetsWebstormCode Completion

Phpstorm Problem Overview


I use PhpStorm. I want to make snippets of code and then assign shortcuts to them. I can do it in NetBeans, but in PhpStorm I don't know how to make them.

For example, to add console.log(); in NetBeans, I only type con + space. con is the shortcut that I had defined.

Phpstorm Solutions


Solution 1 - Phpstorm

In IntelliJ (the Java IDE) or PhpStorm (the PHP IDE) it is called Live Templates.

Go to Settings and start typing "live templates" in the search box. On the right panel you can edit and create such templates.

So in your case, you simply type "con" in the abbreviation text box and "console.log();" in the template box text area below. You may even change, with which action you want to expand the template (Tab is default, space and enter are possible).

The live template thing is much more complex than what I wrote above. You can use variables and some context information. For further reading, I suggest the JetBrains / PhpStorm documentation.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAladdin MhemedView Question on Stackoverflow
Solution 1 - PhpstormsynopiaView Answer on Stackoverflow