Cool Snippets

Shortcuts for snippets (Look at the double slash (//) for shortcut)
mail@pastecode.io avatar
unknown
javascript
a year ago
2.1 kB
2
Indexable
Never
{
  // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
  // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
  // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
  // used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
  // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
  // Placeholders with the same ids are connected.
  // Example:

  // Shortcut is "cl"
  "Print to console": {
    "scope": "javascript,typescript",
    "prefix": "cl",
    "body": ["console.log();"],
    "description": "Log output to console"
  },
  // Shortcut is "fn"
  "Call a function": {
    "scope": "javascript,typescript",
    "prefix": "fn",
    "body": ["function $1() {", "  $2", "}"],
    "description": "Make a function"
  },
  // Shortcut is "elsf"
  "auto completion of else if": {
    "scope": "javascript,typescript",
    "prefix": "elsf",
    "body": [" else if $1() {", "  $2", "}"],
    "description": "Make a function"
  },
  // Shortcut is "els"
  "auto completion of else": {
    "scope": "javascript,typescript",
    "prefix": "els",
    "body": [" else $1() {", "  $2", "}"],
    "description": "Make a function"
  },
  // Shortcut is "fl+"
  "auto completion of for loop+": {
    "scope": "javascript,typescript",
    "prefix": "fl+",
    "body": ["for (let i = 0; i <$1 .length; i++) {", "  $2", "}"],
    "description": "Make a forwards for loop"
  },
  // Shortcut is "fl-"
  "auto completion of for loop-": {
    "scope": "javascript,typescript",
    "prefix": "fl-",
    "body": ["for (let i =$1 .length - 1; i >= 0; i--) {", "  $2", "}"],
    "description": "Make a backwards for loop"
  },
  // Shortcut is "fl"
  "auto completion of for loop": {
    "scope": "javascript,typescript",
    "prefix": "fl",
    "body": ["for (let i$1; i; i) {", "  $2", "}"],
    "description": "Make a general for loop"
  }
}