问题
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>
)
回答1:
From the 0.3.0 release notes
HTML auto closing of tags has now been removed and replaced with smarter IntelliSense on
</
.
回答2:
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 :
- type
<div
- press Tab
- press Tab
it will add the closing tag
回答3:
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
回答4:
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.
回答5:
You could try this extension for VS Code. It has implemented the auto close tag function and would meet with your requirement:
- Automatically add closing tag when you type in the closing bracket of the opening tag
- After closing tag is inserted, the cursor is between the opening and closing tag
回答6:
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.
回答7:
File > Preferences > Keymaps, Search 'Auto close' and click on install. If it doesn't work, reload the plugin.
回答8:
i was also suffering from the same problem . now i have uninstall unnecessary extensions from vs code along with JavaScript (SE) extension and now its working file .Hope this will work for you.
来源:https://stackoverflow.com/questions/30696863/vscode-not-auto-completing-html