3

I want c to trigger console.log()

The snippet I created has the correct syntax below and is in the correct folder paths according to these articles: http://www.hongkiat.com/blog/sublime-code-snippets/ | http://sublimetext.info/docs/en/extensibility/snippets.html

enter image description here

<snippet>
    <content><![CDATA[
console.log(${1:this});
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>c</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.JavaScript</scope>
</snippet>

I have the snippet file created inside of my User folder, as well a User/Javascript folder. It has the correct sublime-snippet extension as well.

Went through the trouble of installing the JavaScript default snippets, but now instead of just console it does console.dir(obj) who uses that lol? Anyways if I can't create my own custom snippets, how can I edit this one?

4
  • The scope should be source.javascript. The J and the S are not capitalized.
    – MattDMo
    Jun 14, 2016 at 15:29
  • I tried that as well, did not work :( I finally got it to work when I removed the <scope> line though, however now c will work in all scopes.
    – Leon Gaban
    Jun 14, 2016 at 15:40
  • 1
    Nevermind, I just checked - it's source.js. My bad.
    – MattDMo
    Jun 14, 2016 at 15:42
  • Ah thanks! That was it, want to post the answer? @MattDMo
    – Leon Gaban
    Jun 14, 2016 at 15:48

1 Answer 1

5

The base scope for JavaScript files in Sublime is source.js, not source.javascript. You can find the complete scope at the cursor by hitting CtrlAltShiftP (Linux/Windows) or AltP (OS X).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .