VSCode 不自动完成 HTML
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30696863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VSCode not auto completing HTML
提问by Harvey3589661
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.
我在 Windows 7 上使用新安装的 Visual Studio Code 时遇到问题。在 Mac 上,编辑器会自动关闭 html 标签,但在我的 Win7 上不会。我认为必须有一些选项可以打开它,但我找不到任何选项。
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>
)
我说的是当例如。编写<html
intelliSense 弹出并单击回车,通常它会自动放入</html>
地雷不工作。(智能感知弹出但是当你选择它不会自动关闭标签的选项之一:<h1> -> </h1>
)
采纳答案by John Papa
From the 0.3.0 release notes
HTML auto closing of tags has now been removed and replaced with smarter IntelliSense on
</
.
标签的 HTML 自动关闭现在已被删除,取而代之的是更智能的 IntelliSense on
</
。
回答by Rabolf
Type the tag name (without starting <
) then press Tab
输入标签名称(不开始<
)然后按 Tab
for example type div
then press tab and VS will convert it to <div></div>
例如输入div
然后按 Tab 键,VS 会将其转换为<div></div>
Or type the opening tag then press Tab twice
或者输入开始标签,然后按两次 Tab
for example :
例如 :
- type
<div
- press Tab
- press Tab
- 类型
<div
- 按 Tab
- 按 Tab
it will add the closing tag
它将添加结束标记
回答by Siphamandla Hero Ngwenya
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
我遇到了同样的问题,然后我在 vs 代码的右下角看到了一些东西。我没有使用 HTML,而是使用 Django-HTML,所以我将语言更改为 html,Boom 一切又正常了。看图片
回答by ?????
Here is a cool trick (actually an Emmet abbreviation):
这是一个很酷的技巧(实际上是 Emmet 的缩写):
- write the tag name - |e.g.
h1
- add an asterisk after that - |e.g.
h1*
- press Tab- |(will result in
<h1></h1>
)
- 写标签名称 - | 例如
h1
- 在那之后添加一个星号 - | 例如
h1*
- 按Tab- | (将导致
<h1></h1>
)
-
——
PS:This also works for self-closing tags, such as - input
, img
etc.
PS:这也适用于自闭的标签,如: - input
,img
等等。
回答by Jun Han
You could try this extensionfor VS Code. It has implemented the auto close tag function and would meet with your requirement:
你可以试试这个VS Code扩展。它实现了自动关闭标签功能,将满足您的要求:
- 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
- 键入开始标记的结束括号时自动添加结束标记
- 插入结束标签后,光标在开始和结束标签之间
回答by X.X
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.
在编辑 HTML 文件时,我在 Mac Sierra (10.12.6) 和 VSCode (1.30.2) 上遇到了同样的问题。根据 vscode 文档https://code.visualstudio.com/docs/languages/html,智能感知应该开箱即用。
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.
原来,“语言检测”(在屏幕底部编辑器状态栏的右上角)设置为自动检测,并将文件识别为django-html
. 当手动切换回纯 Html 时,一切正常。
回答by Dheemanth Bhandarkar
File > Preferences > Keymaps, Search 'Auto close' and click on install. If it doesn't work, reload the plugin.
文件 > 首选项 > 键盘映射,搜索“自动关闭”并单击安装。如果它不起作用,请重新加载插件。
回答by Khapi
- Press Ctrl + Shift + Pto open the command palette.
- Type 'Change Language Mode'in the searcher.
- Select 'Change Language Mode'.
- Type 'HTML'in the searcher.
- And select 'HTML'(it was probably set to 'django-html)
- 按Ctrl + Shift + P打开命令面板。
- 键入“更改语言模式”的搜索。
- 选择“更改语言模式”。
- 键入“HTML”中的搜索。
- 并选择'HTML'(它可能被设置为'django-html)
回答by skipper
Probably set from 'django-html' to 'html' in bottom right. that's work for my, thank you people.
可能从右下角的“django-html”设置为“html”。这对我有用,谢谢大家。
回答by Ali
Press Ctrl + Shift + P
to open the command.
Then, type Change Language Mode
an select HTML
or any other desired language.
按Ctrl + Shift + P
打开命令。然后,键入Change Language Mode
选择HTML
或任何其他所需的语言。