Harvey3589661
Harvey3589661

Reputation: 1295

VSCode not auto completing HTML

I'm having trouble with my new installed Visual Studio Code on Windows 7. On Mac the editor automatically closes html tags but on my Win7 not. I assume there must be some option to turn it on but I can't find any.

I'm talking about when eg. writing <html the intelliSense pops up and you click enter, usually it automatically puts in the </html> mine's not working. (The IntelliSense pops up but when you select one of the options it doesn't auto close the tag: <h1> -> </h1>)

Upvotes: 128

Views: 243845

Answers (17)

tisohjung
tisohjung

Reputation: 31

Goto Settings cmd+,

find Emmet: Included Languages add

add Item django-html Value html

django-html

Upvotes: 1

Fuad Alizade
Fuad Alizade

Reputation: 31

If HTML tags autocompleting issue is on JavaScript files, then you just need to change "select language mode" from "JavaScript" to "JavaScript React".

Upvotes: 2

Guillermo Brachetta
Guillermo Brachetta

Reputation: 4745

If you want to keep "Django HTML" as the file language and still have auto-closing tags, just add the following to settings.json (provided you have the auto close tag extension installed):

  "auto-close-tag.activationOnLanguage": [
    "django-html",
    (...other languages if needed)
  ],

Upvotes: 5

Krishna
Krishna

Reputation: 347

Change from Django-html to html .enter image description here

Upvotes: 26

Syed Shahzaib Hussain
Syed Shahzaib Hussain

Reputation: 322

  1. List item Goto Settings: File -> Preferences -> Settings (CTRL + COMMA shortkey in Ubuntu).
  2. In Search Bar type Emmet.
  3. Find Trigger Expansion On Tab and check it.

Upvotes: 8

IFTEKHAR I ASIF
IFTEKHAR I ASIF

Reputation: 395

If you type

div.class

and then press TAB, VS code will automatically close the DIV tag with the given CLASS

But I think you want to do this operation by pressing the ENTER key.

In that case, go to your VS Code user setting & paste the following code:

"emmet.includeLanguages": {
    "javascript": "javascriptreact",
    "vue-html": "html",
    "razor": "html",
    "plaintext": "jade"
}

Now if you type

div.class

& then press the ENTER key, you can see the magic.

However, the above code will make your VS Code auto-completion with ENTER key not only for normal HTML but also the JSX of React, Vue.js snippets will also cover by this.

But If you want to do it only for HTML file, just the following line is enough:

"emmet.includeLanguages": { "javascript": "html" }

Cheers..

Upvotes: 2

suvalakshmi
suvalakshmi

Reputation: 61

Press ๐œ๐ญ๐ซ๐ฅ+๐ฌ๐ก๐ข๐Ÿ๐ญ+๐ --> type in ๐‚๐ก๐š๐ง๐ ๐ž ๐‹๐š๐ง๐ ๐ฎ๐š๐ ๐ž ๐Œ๐จ๐๐ž --> then select ๐€๐ฎ๐ญ๐จ ๐ƒ๐ž๐ญ๐ž๐œ๐ญ

It works for me.

Upvotes: 6

Otee
Otee

Reputation: 108

Just check the bottom of your vscode and change the language mode to HTML It might have been showing django-html or click ctrl + shift + p to change the language mode Screenshot

Now click [!] + TAB voila it's done!!!

Upvotes: 1

Mehedi Hasan Shifat
Mehedi Hasan Shifat

Reputation: 720

I was suffering from the same problem,then I uninstalled unnecessary extensions from VS Code along with JavaScript (SE) extension and it worked for me.

Upvotes: 1

Ali
Ali

Reputation: 684

Press Ctrl + Shift + P to open the command. Then, type Change Language Mode an select HTML or any other desired language.

Upvotes: 2

Khapi
Khapi

Reputation: 650

  1. Press Ctrl + Shift + P to open the command palette.
  2. Type 'Change Language Mode' in the searcher.
  3. Select 'Change Language Mode'.
  4. Type 'HTML' in the searcher.
  5. And select 'HTML' (it was probably set to 'django-html)

Upvotes: 19

John Papa
John Papa

Reputation: 22298

From the 0.3.0 release notes

HTML auto closing of tags has now been removed and replaced with smarter IntelliSense on </.

Upvotes: 53

X.X
X.X

Reputation: 981

I've encountered same problem on Mac Sierra (10.12.6) with VSCode (1.30.2), while editing an HTML file. According to the vscode documentations https://code.visualstudio.com/docs/languages/html, the intellisense should work out of box.

Turned out that the "Language Detection" (on the right corner of editor status bar at the bottom of screen) is set to Automatic Detection, and recognized the file as django-html. When manually switched back to plain Html, everything works.

Upvotes: 9

Siphamandla Ngwenya
Siphamandla Ngwenya

Reputation: 3064

I was experiencing the same problem, then i saw something on my bottom right of vs code.. instead of using HTML, i was using Django-HTML, so i changed the language to html, Boom everything is working fine again.see image

Upvotes: 226

Dheemanth Bhandarkar
Dheemanth Bhandarkar

Reputation: 360

File > Preferences > Keymaps, Search 'Auto close' and click on install. If it doesn't work, reload the plugin.

Upvotes: 2

Here is a cool trick (actually an Emmet abbreviation) :

  • write the tag name ยญ | e.g. h1
  • add an asterisk after that ยญ | e.g. h1*
  • press Tab ยญ | (will result in <h1></h1>)

ยญ

PS: This also works for self-closing tags, such as - input , img etc.

Upvotes: 32

Reza Abolfathi
Reza Abolfathi

Reputation: 3181

Type the tag name (without starting <) then press Tab

for example type div then press tab and VS will convert it to <div></div>

Or type the opening tag then press Tab twice

for example :

  1. type <div
  2. press Tab
  3. press Tab

it will add the closing tag

Upvotes: 220

Related Questions