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

Installs

  • Total 71K
  • Win 47K
  • OS X 14K
  • Linux 10K
May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8
Windows 20 37 64 25 27 53 42 29 31 41 15 20 27 36 32 39 21 13 13 33 27 36 28 19 17 20 29 31 27 26 36 24 38 21 40 41 42 49 14 28 35 33 64 35 38 33
OS X 4 3 6 2 3 9 7 10 5 7 2 5 5 4 3 8 2 3 4 3 9 5 3 2 2 7 9 1 3 4 2 6 8 2 5 8 6 8 3 3 14 6 13 6 8 6
Linux 3 4 3 4 5 6 3 2 5 6 0 4 7 8 7 6 2 3 4 5 4 7 4 6 3 4 9 7 6 7 4 4 3 3 5 4 3 4 2 6 1 4 7 5 5 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}
};