Any shortcut in WebStorm to surround a block of code with an IIFE

That is, if I have a function like:

angular.module('sessionController',[]);

      

and I want to change it to

(function () {
    'use strict';

     angular.module('sessionController',[]);

}());

      

I thought there would be a "code / surround with" option

+3


source to share


1 answer


You can create a corresponding Live Template (Settings / Live Templates) as shown below:

(function () {
    'use strict';

     $SELECTION$

}());

      



Be sure to set the context (Applicable B ...) to "JavaScript".

The template can be applied using Code/Surround with live template (Ctrl+Alt+J)

+9


source







All Articles