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
  • 42 minutes ago
  • 6 years ago

Installs

  • Total 74K
  • Win 50K
  • OS X 14K
  • Linux 10K
Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 Jul 27 Jul 26 Jul 25 Jul 24 Jul 23 Jul 22 Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3
Windows 6 35 27 27 45 27 12 23 28 29 33 48 11 9 30 29 36 22 37 17 21 32 33 29 36 35 21 20 32 23 34 28 35 18 22 18 32 25 38 45 21 21 18 41 25 35
OS X 1 3 5 4 5 1 3 7 5 6 9 3 4 5 2 5 7 6 8 2 2 6 6 5 4 6 2 1 8 9 9 7 6 2 3 8 9 3 6 4 2 4 5 8 9 11
Linux 0 7 7 6 5 2 4 3 3 6 6 10 4 7 5 2 2 7 5 2 2 4 6 4 5 8 2 1 3 5 5 2 2 2 2 4 9 9 5 5 5 5 6 4 4 9

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