Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to autocomplete Vue templates in Visual Studio Code

I am starting to learn Vue, using Visual Studio Code. I downloaded an extension that adds Vue code snippets (Vue 2 Snippets by hallowtree).

When I start to type "v" in a Vue template, suggestions are shown (v-on, v-bind, etc.), but afterward, no suggestions or autocompletions are shown.

In the following example template, v-on is suggested, but afterward, no suggestions for "click" or any other event. Also, nothing is suggested after "@":

<button v-on:click="changeLink">Click to change Link</button>
<button @click="changeLink">Click to change Link</button>

And in this example, v-bind is suggested, but afterward, no suggestions for "href" or any other HTML properties/attributes:

<a v-bind:href="link">Link</a> 
<a :href="link">Link</a>

Although it's good for me for practicing, it will become a liability. Are there any extensions, options, or commands I can set up to improve the developer experience?

like image 375
eomer Avatar asked Aug 13 '19 22:08

eomer


People also ask

How do I autocomplete code in Visual Studio?

You can trigger IntelliSense in any editor window by typing Ctrl+Space or by typing a trigger character (such as the dot character (.) in JavaScript). Tip: The suggestions widget supports CamelCase filtering, meaning you can type the letters which are upper cased in a method name to limit the suggestions.

What is the Vetur?

Vetur provides syntax highlighting for all your Vue source code files. Without Vetur, a .vue file will be displayed in this way by VS Code: with Vetur installed: VS Code is able to recognize the type of code contained in a file from its extension.


2 Answers

Vetur has had experimental template interpolation for autocomplete and "diagnostics / hover / definition / references" within HTML templates since February 2019.

Enable the Vetur › Experimental: Template Interpolation Service option in your VS Code settings to turn on this feature.

like image 73
Franey Avatar answered Oct 22 '22 18:10

Franey


add the Vetur extension on visual-studio-code it includes many other nice features besides auto completion vue code

like image 45
Abdelillah Aissani Avatar answered Oct 22 '22 18:10

Abdelillah Aissani