LastM4N
LastM4N

Reputation: 2230

Vue.js - when creating new Vue File pass automatically name attribute

I am searching for a way when creating new Vue.js files to pass automatically the name attribute.

For example, when I create a new Vue file with name Test.vue, to generate this automatically:

<template></template>

<script>
export default {
    name: 'Test',
};
</script>

<style></style>

To add the name attribute based on the file name creation. Is there any automated way in order to stop adding this manually every time I create Vue file?

Thanks!

Upvotes: 1

Views: 453

Answers (1)

STh
STh

Reputation: 802

I would suggest you take a look at this: Custom snippets in VS Code. I do not know a way how to invoke a script on creation of a file, but you could choose a keybinding like "default" which would create a snippet as you wish.

To my knowledge, it would even be possible to set where the cursor will end up, so that you would still have to type the filename manually, but it would immensely speed up your workflow.

You may find more information on this StackOverflow post, or take a look at the VS Code documentation to this topic

Upvotes: 1

Related Questions