I'm searching for shortcut in WebStorm for auto completing my html code. So in my case if I write code like .row and press something it should automatically write <div class="row"></div>.
2 Answers
Such "transformation" (abbreviation expansion) called Emmet .. and by default it uses Tab key.
But it can also be Enter or Space .. or even custom key of your choice -- you can change it at Settings/Preferences | Editor | Emmet
P.S. For big chunks of code -- have a look at Live Templates (Code Snippets).
3 Comments
Tung
Btw, do you know how can we export these code snippets to back up or share them with others?
LazyOne
@Tung What "code snippets" exactly? If you are referring to the standard Emmet abbreviations.. then they are standard ones already (docs.emmet.io/cheat-sheet) so if your editor/IDE supports Emmet it should have them already. If standard Live Templates -- well, they are standard for IDE (bundled) so no need to share anything. For custom Live Templates that you can create yourself -- jetbrains.com/help/phpstorm/… -- they are stored in
templates subfolder.Tung
Thank you for the link of abbreviations cheat sheet. It answers my question. If they were implemented by default, we don't need to save the configuration for them.
div.rowand hit Tab it will do it. Otherwise how is it supposed to know what element you want that class to be on?divtag with that class applied to it.Tabis default .. but it can also beEnterorSpace.. or even custom key of your choice --Settings/Preferences | Editor | Emmet