ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

JS Snippets

by RadLikeWhoa ST2/ST3

JavaScript snippets for Sublime Text 2.

Labels snippets

Details

  • 2014.07.20.16.49.16
  • github.​com
  • github.​com
  • 3 years ago
  • 1 hour ago
  • 5 years ago

Installs

  • Total 62K
  • Win 41K
  • OS X 12K
  • Linux 9K
Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4
Windows 42 36 44 35 26 41 39 50 23 60 49 31 29 40 35 36 67 44 15 37 42 66 52 55 49 26 43 40 54 61 69 60 39 50 60 76 61 67 30 28 38 46 48 41 48 52
OS X 10 13 6 6 7 7 11 4 7 10 6 9 3 5 7 6 10 11 3 12 14 11 8 9 21 11 11 11 13 12 18 19 12 12 12 18 9 14 12 5 5 19 12 13 9 11
Linux 6 3 8 5 6 7 7 10 5 8 8 6 4 9 6 12 6 7 8 8 7 10 8 8 8 4 5 9 2 14 12 10 3 10 8 9 7 4 7 9 6 9 8 11 7 3

Readme

Source
raw.​githubusercontent.​com

Sublime Text 2 JS Snippets

In order to use the snippets, just enter the shortcode and press the Tab (or whatever you have set as completion key) to use the snippets.

Included are all snippets listed below. $1, $2, etc. show the position where the caret will appear whenever you press the tab key inside the snippet.

These snippets are intended to be used by regular people trying to make their JavaScript development a little easier. If you want more complex snippets, use JP Richardson's JavaScript snippets.

You're free to alter the snippets in any way imaginable. Add new ones, remove old ones, do whatever you like. If you've found something interesting, go ahead and make a pull request or send me a tweet.


cls

localStorage.clear();

do

do {
    ${1:expression}
} while (${2:condition});

eve

${1:element}.addEventListener('$2', function (e) {
    $3
}, false);

if

if (${1:condition}) {
    ${2:expression}
}

ife

if (${1:condition}) {
    ${2:expression}
} else {
    ${3:other expression}
}

interval

setInterval(${1:function}, ${2:delay});

for

for (${1:var i = 0}; ${2:i < ${3:elements.length}}; ${4:i++}) {
    ${5:expression}
}

fori

for (${1:prop} in ${2:object}) {
    if (${2:object}.hasOwnProperty(${1:prop})) {
        ${3:expression}
    }
}

log

console.log(${1:'test'});

ls

if (localStorage.${1:item}) {
    var ${1:item} = localStorage.${1:item};
    $2
}

pd

e.preventDefault();

rand

Math.floor(Math.random() * ${1:10})

switch

switch(${1:var}) {
    case $2:
        $3
        break;
    case $4:
        $5
        break;
}

timeout

setTimeout(${1:function}, ${2:delay});

while

while (${1:condition}) {
    ${2:expression}
};