Giter Club home page Giter Club logo

vscode-javascript-snippet-pack's Introduction

JavaScript Snippet Pack for Visual Studio Code

Download this extension from the Visual Studio Code Marketplace

Sponsors


Request and perform code reviews from inside your IDE. Review any code, even if it's a work-in-progress that hasn't been committed yet, and use jump-to-definition, your favorite keybindings, and other IDE tools.
Try it free

Usage


A snippet pack to make you more productive working with JavaScript. Based on Visual Studio extension by Mads Kristensen, which is based on Atom snippets.

This extension ships a bunch of useful code snippets for the JavaScript and TypeScript editors.

Here's the full list of all the snippets:

Console

[cd] console.dir

console.dir(${1});

[ce] console.error

console.error(${1});

[ci] console.info

console.info(${1});

[cl] console.log

console.log(${1});

[cw] console.warn

console.warn(${1});

[de] debugger

debugger;

DOM

[ae] addEventListener

${1:document}.addEventListener('${2:load}', function(e) {
	${3:// body}
});

[ac] appendChild

${1:document}.appendChild(${2:elem});

[rc] removeChild

${1:document}.removeChild(${2:elem});

[cel] createElement

${1:document}.createElement(${2:elem});

[cdf] createDocumentFragment

${1:document}.createDocumentFragment();

[ca] classList.add

${1:document}.classList.add('${2:class}');

[ct] classList.toggle

${1:document}.classList.toggle('${2:class}');

[cr] classList.remove

${1:document}.classList.remove('${2:class}');

[gi] getElementById

${1:document}.getElementById('${2:id}');

[gc] getElementsByClassName

${1:document}.getElementsByClassName('${2:class}');

[gt] getElementsByTagName

${1:document}.getElementsByTagName('${2:tag}');

[ga] getAttribute

${1:document}.getAttribute('${2:attr}');

[sa] setAttribute

${1:document}.setAttribute('${2:attr}', ${3:value});

[ra] removeAttribute

${1:document}.removeAttribute('${2:attr}');

[ih] innerHTML

${1:document}.innerHTML = '${2:elem}';

[tc] textContent

${1:document}.textContent = '${2:content}';

[qs] querySelector

${1:document}.querySelector('${2:selector}');

[qsa] querySelectorAll

${1:document}.querySelectorAll('${2:selector}');

Loop

[fe] forEach

${1:array}.forEach(function(item) {
	${2:// body}
});

Function

[fn] function

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

[afn] anonymous function

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

[pr] prototype

${1:object}.prototype.${2:method} = function(${3:arguments}) {
	${4:// body}
}

[iife] immediately-invoked function expression

(function(${1:window}, ${2:document}) {
	${3:// body}
})(${1:window}, ${2:document});

[call] function call

${1:method}.call(${2:context}, ${3:arguments})

[apply] function apply

${1:method}.apply(${2:context}, [${3:arguments}])

[ofn] function as a property of an object

${1:functionName}: function(${2:arguments}) {
	${3:// body}
}

JSON

[jp] JSON.parse

JSON.parse(${1:obj});

[js] JSON.stringify

JSON.stringify(${1:obj});

Timer

[si] setInterval

setInterval(function() {
	${0:// body}
}, ${1:1000});

[st] setTimeout

setTimeout(function() {
	${0:// body}
}, ${1:1000});

Misc

[us] use strict

'use strict';

[al] alert

alert('${1:msg}');

[co] confirm

confirm('${1:msg}');

[pm] prompt

prompt('${1:msg}');

License

MIT License

vscode-javascript-snippet-pack's People

Contributors

akamud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vscode-javascript-snippet-pack's Issues

Custom body formats

Provide some interface to custom body formats.

Usually I would like to generate formats as:

console.log(
  $1
)
${1:document}
  .createElement(
    ${2:elem}
  )

[Request] Publish extension on open-vsx.org

Hi there!

I'm reaching out to you because we currently have your extension manually added to our extension gallery at Coder for code-server, and we're currently working on a migration to open-vsx, which is also used by other community VSCode forks (including, but not limited to Arch Linux's Code-OSS builds and VSCodium).

We (and other open source VSCode forks) cannot use Microsoft's extension gallery, as MS' terms of service allows only the proprietary MS products to interact with the official gallery.

We'd really appreciate it if you can add your extension to open-vsx! A simple guide on publishing extensions to Open-VSX is available here.

How do you invoke these?

I'm having trouble understanding how to quickly access these snippets. The only method I've found is to do ctrl+shift+p, type "sni", hit down twice, then type the snippet name. Is that how this works? Is there a way to simply type "cl" then and how it expand to console.log()?

Optional semicolons

Semicolons are optional. I think that who use it should add instead of who doesn't use have to remove it as an obstacle.

At least provide some interface to omit it, something like:

cl ~~> console.log($1)

cl; ~~> console.log($1);

Not working

Instruction would be nice.
Installed on VSC 1.9.1.
I type 'ae' and wait for suggestion to show up and then select it form drop down and expand to 'add event list... ' .
When i type 'cl' and press tab nothing happens, press Enter nothing

cl is conflict with class

cl doesn't work. Because it is conflict with class from default.
maybe we should use a different token ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.