Skip to content

Snippets for JavaScript / JS Programming in Sublime Text 2

Notifications You must be signed in to change notification settings

sdempsey/sublime-js-snippets

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sublime Text Editor 2 - JavaScript Snippets

JavaScript / JS snippets for your Sublime Text 2 Fu.

Install

Sublime Text 2 - Package Control

Install via package control: http://wbond.net/sublime_packages/community Search for JavaScript Snippets or typically the keywords js or javascript are suitable.

Mac OS X

git clone git://github.com/jprichardson/sublime-js-snippets.git ~/Library/Application Support/Sublime Text 2/Packages/JavaScript

Linux

git clone git://github.com/jprichardson/sublime-js-snippets.git ~/.config/sublime-text-2/Packages/JavaScript

Windows

git clone git://github.com/jprichardson/sublime-js-snippets.git %userprofile%\AppData\Roaming\Sublime Text 2\Packages\JavaScript

Vanilla Snippets

[afn] anonymous function

function(${1:arguments}) {
	${0:// body...}
}

[cd] console.dir

console.dir(${1:obj})${0}

[ce] console.error

console.error(${1:error})${0}

[cl] console.log

console.log(${1:msg})${0}

[cli] console.log with util.inspect

console.log(require('util').inspect(${1:obj}, true, ${2:10}, true))${0}

[ct] console.trace

console.trace(${1:msg})${0}

[fn] function

function ${1:methodName}(${2:arguments}) {
	${0:// body...}
}

[ii] Immediately-invoked function expression

(function () {
	${0:// body...}
})();

[me] module.exports

module.exports = ${1}

[okfe] Objects.keys and forEach

Object.keys(${1:obj}).forEach(function(key) {
	${0:// body...}
})

[pe] process.exit

process.exit()

[proto] prototype

${1:ClassName}.prototype.${2:methodName} = function(${3:arguments}) {
	${0:// body...}
}

[req] require

require('${1:package}')${0}

[sto] setTimeout

setTimeout(function() {
	${2:// body...}
}, ${1:millis})

[sti] setInterval

setInterval(function() {
	${2:// body...}
}, ${1:millis})

[us] use strict

'use strict'

Behaviorial Driven Development

[desc] describe

describe('${1:description}', function() {
	${0:// body...}
})

[ita] asychronous it

it('${1:description}', function(done) {
	${0:// body...}
})

[its] synchronous it

it('${1:description}', function() {
	${0:// body...}
})

Author

JP Richardson

License

Copyright 2012, JP Richardson jprichardson@gmail.com

MIT

About

Snippets for JavaScript / JS Programming in Sublime Text 2

Resources

Stars

Watchers

Forks

Packages

No packages published