Live Template not working

Hi,

I'm just getting started with webstorm and I can't get my live templates to work.

As you can see in the image I created a simple javascript console.log() method. But when I type clog and then tab on the editor nothing happens.

Also I've created a more complex, multi-line template for a regular HTML5 file with the same results.

Console Template:

HTML5 Template:

I'm pretty sure that I'm missing something here but after going through the docs (https://www.jetbrains.com/help/phpstorm/2016.2/live-templates.html) I'm still running into the same issue.

I'm using version 2016.2.2

Thanks,

Rodrigo.

8 comments
Comment actions Permalink

The problem is the same for both templates - you didn't specify the context, that's why templates can't be applied. Note the 'No applicable contexts. Define' shown beneath the template editor... Just click the Define link and select the context (JavaScript for console.log(), HTML - for your HTML template)

3
Comment actions Permalink

DO'H!!!!! 

Thanks and sorry for the stupidity ;)

I don't know if I can follow up with a non-related question (is about webstorm but not the same issue though). I'm still a fan of CDN's and for the same reason I keep a local copy of different versions of some frameworks I frequently use in a specific folder of my local server. I normally use an absolute path to reach those files like: /scripts/gsap/1.18.3/uncompressed/TweenMax.js

Is there a way to use absolute paths in webstorm file autocomplete to avoid going back several folders in order to avoid this: ../../../scripts/gsap/blah-blah?

Thanks,

Rodrigo.

0
Comment actions Permalink

If you start your path in `<script src=` with slash and then hit Ctrl+space, WebStorm will suggest files/folders in your project root. So, if your absolute paths start in your project root, then yes, you can get the completion

1
Comment actions Permalink

Thanks Elena,

But the path is always relative to the project root, not the filesystem, right?

0
Comment actions Permalink

Right. It's relative either to project root or to the folder marked as Resource root

0
Comment actions Permalink

So even after reading this I couldnt find where to set the context. 

Found it with the help of youtube. 

Anyway at the bottom there is a blue text "change" you have to click to bring up the context menu. Jetbrains and settings...


0
Comment actions Permalink

See Live Templates—WebStorm (jetbrains.com):

Change Click this link to modify the set of contexts where the current template is enabled. Upon clicking the link, a list of supported language contexts is displayed. To make WebStorm consider a context sensitive to the template, select a checkbox next to the context name.

The available context types depend on the enabled plugins.

0
Comment actions Permalink

My point was about the settings UI that is just plain bad. Youtube should not be needed to figure this stuff out. 

The page you link to doesn't have a realworld example, screenshot etc.. 

Again, jetbrains settings are a lot of work, much can be made easier by having a good ui

0

Please sign in to leave a comment.