Skip to content

Instantly share code, notes, and snippets.

@juliovedovatto
Last active November 5, 2021 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliovedovatto/75d573c6b6c7e07b00c34f4f91434ad8 to your computer and use it in GitHub Desktop.
Save juliovedovatto/75d573c6b6c7e07b00c34f4f91434ad8 to your computer and use it in GitHub Desktop.
VSCode Vetur Snippet for Vue 2.x components
<template>
<div class="${TM_FILENAME_BASE/(^[A-Z])|([A-Z])/${2:+-}${2:/downcase}${1:/downcase}/g}"></div>
</template>
<script>
export default {
name: '${TM_FILENAME_BASE}',
components: {},
props: {},
data() {
return {}
},
computed: {},
watch: {},
mounted() {},
methods: {}
}
</script>
<style lang="scss" scoped>
.${TM_FILENAME_BASE/(^[A-Z])|([A-Z])/${2:+-}${2:/downcase}${1:/downcase}/g} {
position: relative;
}
</style>
@juliovedovatto
Copy link
Author

To add this snippet just open command palette and select Vetur: Open user scaffold snippet folder. This action will open a new VSCode Editor and you be able to create a snippet file with the code above.

@juliovedovatto
Copy link
Author

Example: TrackerSearchForm.vue

Output:

<template>
  <div class="tracker-search-form"></div>
</template>

<script>
export default {
  name: 'TrackerSearchForm',
  components: {},
  props: {},
  data() {
    return {}
  },
  computed: {},
  watch: {},
  mounted() {},
  methods: {}
}
</script>

<style lang="scss" scoped>
.tracker-search-form {
  position: relative;
}
</style>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment