Search code examples
intellij-ideawebstorm

Shortcut for create javascript function on webstorm / intellij


I've seen on EggHead blog's some videos about coding AngularJS javascript apps. I realize that every time that he type $scope.x = fun the code completion open and he types some shortcut (which I don't know) that creates the following statement:

$scope.x = function () {
}

The normal code complete, ctrl + space, gives me:

$scope.x = function

Does anybody knows this shortcut or how to configure that?


Solution

  • Most likely he has a custom Live Template configured that expands fun with Tab into:

    function () {
    }
    

    The template may look like this:

    function () {
      $END$
    }
    

    Where $END$ stands for the final cursor position after expanding.