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
  • 4 years ago
  • 1 hour ago
  • 6 years ago

Installs

  • Total 76K
  • Win 51K
  • OS X 14K
  • Linux 10K
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 Sep 3 Sep 2 Sep 1
Windows 22 27 19 36 24 40 36 27 35 13 19 25 21 28 25 32 27 35 26 36 34 26 19 12 17 26 35 35 26 29 14 16 25 23 27 23 38 23 12 19 21 39 33 30 22 14
OS X 1 7 0 3 1 6 4 3 5 4 3 4 3 3 2 5 3 4 4 4 4 10 7 2 2 4 4 6 5 2 2 5 3 4 9 6 7 4 0 6 7 3 3 7 1 2
Linux 1 7 3 1 2 5 5 4 5 5 7 3 6 2 5 13 2 2 4 2 9 3 4 1 3 5 5 5 2 7 2 3 10 6 4 9 6 2 3 7 5 1 6 3 2 8

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}
};