/JavaScriptSnippetPack

A Visual Studio extension

Primary LanguageVim SnippetOtherNOASSERTION

JavaScript Snippet Pack for Visual Studio

Build status

Download this extension from the VS Gallery or get the nightly build.


A snippet pack to make you more productive working with JavaScript. Based on the Atom snippets.

Snippet manager

This extension ships a bunch of useful code snippets for the JavaScript editor. Get an overview from the Code Snippet Manager in Visual Studio located under the Tools top level menu.

Snippet manager

Here's the full list of all the snippets:

Console

[cd] console.dir

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

[ce] console.error

console.error($end$);

[ci] console.info

console.info($end$);

[cl] console.log

console.log($end$);

[cw] console.warn

console.warn($end$);

[de] debugger

debugger;

DOM

[ae] addEventListener

$document$.addEventListener('$event$', function(e) {
	$end$
});

[ac] appendChild

$document$.appendChild($elem$);

[rc] removeChild

$document$.removeChild($elem$);

[cel] createElement

$document$.createElement($elem$);

[cdf] createDocumentFragment

$document$.createDocumentFragment($elem$);

[ca] classList.add

$document$.classList.add('$class$');

[ct] classList.toggle

$document$.classList.toggle('$class$');

[cr] classList.remove

$document$.classList.remove('$class$');

[gi] getElementById

$document$.getElementById('$id$');

[gc] getElementsByClassName

$document$.getElementsByClassName('$class$');

[gt] getElementsByTagName

$document$.getElementsByTagName('$tag$');

[ga] getAttribute

$document$.getAttribute('$attr$');

[sa] setAttribute

$document$.setAttribute('$attr$', $value$);

[ra] removeAttribute

$document$.removeAttribute('$attr$');

[ih] innerHTML

$document$.innerHTML = '$elem$';

[tc] textContent

$document$.textContent = '$content$';

[qs] querySelector

$document$.querySelector('$selector$');

[qsa] querySelectorAll

$document$.querySelectorAll('$selector$');

Loop

[fe] forEach

$myArray$.forEach(function($item$) {
	$end$
});

Function

[afn] anonymous function

function($arguments$) {
	$end$
}

[pr] prototype

$object$.prototype.$methodName$ = function($arguments$) {
	$end$
}

[call] function call

$methodName$.call($context$, $arguments$)

[apply] function apply

$methodName$.apply($context$, [$arguments$])

[ofn] function as a property of an object

$functionName$: function($arguments$) {
	$end$
}

JSON

[jp] JSON.parse

JSON.parse($object$);

[js] JSON.stringify

JSON.stringify($object$);

Timer

[si] setInterval

setInterval(function() {
	$end$
}, $delay$);

[st] setTimeout

setTimeout(function() {
	$end$
}, $delay$);

Misc

[us] use strict

'use strict';

[al] alert

alert('$message$');

[co] confirm

confirm('$message$');

[pm] prompt

prompt('$message$');

Contribute

Check out the contribution guidelines if you want to contribute to this project.

For cloning and building this project yourself, make sure to install the Extensibility Tools 2015 extension for Visual Studio which enables some features used by this project.

License

Apache 2.0