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
  • 10 minutes ago
  • 5 years ago

Installs

  • Total 65K
  • Win 43K
  • OS X 13K
  • Linux 9K
Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28
Windows 30 49 28 30 33 46 44 40 40 21 35 44 33 43 51 39 31 22 23 28 37 44 42 30 26 49 47 41 36 40 25 33 53 41 49 47 49 29 28 49 55 39 52 58 26 15
OS X 4 8 4 2 9 13 4 11 8 7 4 7 13 15 8 8 9 2 7 5 10 14 10 5 4 7 8 13 10 15 5 2 10 12 12 11 16 13 8 15 14 6 8 15 1 6
Linux 6 8 2 3 13 5 9 15 7 6 5 5 6 4 6 5 10 10 11 4 7 3 9 4 8 10 4 8 2 13 10 8 5 8 8 9 9 11 9 16 8 7 4 9 5 7

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