0.0.6 • Published 3 years ago

vscode-snippets v0.0.6

Weekly downloads
21
License
-
Repository
github
Last release
3 years ago

Useful VS Code Snippets

Visual Studio Code Snippets for daily use with Angular, Vue, Typescript and Javascript.

Use Extension

See the CHANGELOG for the latest changes.

Usage

Type part of a snippet, press enter and the snippet unfolds. Pressing space at anytime shows the description and preview of a snippet.

General Snippets

SnippetDescription
importImport entire module: import Module from 'module'
import-no-nameImport entire module without module name: import 'module'
import-allImport all as alias from module: import * as alias from 'module'
import-partImport only a specific part from a module: import { part } from 'module'
import-asImport only a specific part from a module with an alias: import { part as alias } from 'module'
clogPrint a message to the console: console.log(message)
clogoPrint object to the console: console.log('object': object)
cwarnPrint warning to console: console.warn(message)
ccountPrint occurrences to console: console.count(message)
cdirPrint object represantation: console.dir(object)
cerrorPrint error: console.error(object)
ctablePrint a collection as table: console.table(collection)

Typescript Snippets

SnippetDescription
ts-classClass with Partial constructor assign

Angular Snippets

SnippetDescription
ng-moduleModule
ng-module-with-routingModule with Routing (for child)
ng-serviceService (provided in root)
ng-componentComponent (change detection on push)
ng-directiveDirective
ng-guardGuard (can activate)
ng-interceptorHttp Interceptor
ng-pipePipe
ng-route-404404 Route
ng-route-defaultDefault Route
ng-route-eagerEager loaded Route
ng-route-lazyLazy loaded Route (with new import syntax)
ng-route-childrenRoute with children
ng-output@Output event emitter

Vue 3 Snippets

General

SnippetDescription
vue-sfcVue Single File Component

Javascript / Typescript

SnippetDescription
vue-import-componentImport a component
vue-import-component-dynamicImport a lazy loaded component
vue-import-libImport a library
vue-define-componentVue Typescript component
vue-testUnit test Single File Component
vue-propVue Composition API - prop
vue-refVue Composition API - ref
vue-reactiveVue Composition API - reactive
vue-computedVue Composition API - computed
vue-watchVue Composition API - watch() for single source
vue-watch-arrayVue Composition API - watch() for array of sources
vue-watcheffectVue Composition API - watchEffect()method
vue-life-onmountedVue Composition API - onMounted() Lifecycle hook
vue-life-onbeforemountVue Composition API - onBeforeMount() Lifecycle hook
vue-life-onbeforeupdateVue Composition API - onBeforeUpdate() Lifecycle hook
vue-life-onupdatedVue Composition API - onUpdated() Lifecycle hook
vue-life-onerrorcapturedVue Composition API - onErrorCaptured() Lifecycle hook
vue-life-onbeforeunmountVue Composition API - onBeforeUnmount() Lifecycle hook
vue-life-onunmountedVue Composition API - onUnmounted() Lifecycle hook

Html

Before these snippets started with only v-. New syntax starts with vue-.

SnippetDescription
vue-htmlBind HTML directly to an element with :html
vue-classBind CSS class to an element with :class
vue-ifConditional statement
vue-if-elseConditional statement with else clause
vue-if-else-ifConditional statement with else-if and else clause
vue-showDisplaying or hiding an element with v:show
vue-forLoop
vue-for-indexIndexed loop
vue-for-objectL
vue-for-rangeLoop over a range
vue-onEvent Listener
vue-on-argsEvent Listener with arguments
vue-on-modifiedEvent Listener with event modifier
vue-modelModel
vue-model-numberModel with type number

Vue 2 Snippets

General

SnippetDescription
vue2-componentVue Class Component

Typescript

SnippetDescription
vue2-global-componentRegister a global component
vue2-router-classRouter Class
vue2-route-defaultDefault Route
vue2-route-eagerEager loaded Route
vue2-route-lazyLazy loaded Route
vue2-route-childrenRoute with children
vue2-componentComponent with vue-class-component and vue-property-decorator
vue2-storeDynamic Vuex Store
vue2-store-moduleDynamic Vuex Store Module
vue2-modelInterface and class with create and update functions

Typescript Class Component

All of them need a reference to vue-property-decorator.

Prior these snippets started with only v-. New syntax starts with vue2-class- as these are legacy snippets.

SnippetDescription
vue2-componentGenerates a vue single class component
vue2-class-propProperty
vue2-class-prop-defaultProperty with default value
vue2-class-prop-syncReactive Property
vue2-class-prop-sync-defaultReactive Property with default value
vue2-class-modelModel
vue2-class-watchWatcher
vue2-class-watch-optionsWatcher with default options
vue2-class-emitEvent Emitter - method name is used as $emit
vue2-class-emit-selfEvent Emitter - name is used as $emit
vue2-class-refReference to another component
vue2-class-ref-keyReference to another HTML element

Emmet

If you want intellisense to show emmet before the snippets, you can force the emmet suggestions to show up at the top, by add the following to your editor user settings:

{
  "emmet.showSuggestionsAsSnippets": true,
  "editor.snippetSuggestions": "top"
}
0.0.6

3 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago