简体   繁体   English

VS代码自动标记完成仅选择结束标记

[英]VS code auto tag completion selecting only closing tag

I'm new to vs Code.我是 vs Code 的新手。 I like how when you type a tag in html it automatically adds the closing tag.我喜欢当您在 html 中键入标签时,它会自动添加结束标签。 But sometimes I don't want it because I will have something already written I want to add in between the tags.但有时我不想要它,因为我已经写了一些我想在标签之间添加的东西。

For example, if I already wrote the code and I want to make it bold, I type the opening tag, but then it closes it not surrounding the text.例如,如果我已经编写了代码并且想将其设为粗体,我输入开始标签,但随后它会关闭它而不是围绕文本。 Is there a way I can quickly jump to the end of that closing tag highlighting, or one key that I can hit which will delete that closing tag but leave the opening tag there?有没有一种方法可以快速跳转到该结束标签突出显示的末尾,或者我可以点击一个键来删除该结束标签但将开始标签留在那里?

image of how it starts off:它如何开始的图像:

img 它是如何开始的

image of what I would like to do:我想做的图片:

我想做什么的img

You can use emmet to achieve your goal.您可以使用emmet来实现您的目标。

  1. Frist, you select the word / text / paragraph you want to wrap.首先,您 select 您要换行的单词/文本/段落。

  2. Next you press Ctrl + Shift + P , this lists you all commands available in VSCode.接下来按Ctrl + Shift + P ,这将列出 VSCode 中可用的所有命令。

  3. Search for "Emmet: Wrap with abbreviation" (It's enough to just type emmet into the searchbox)搜索“Emmet: Wrap with abbreviation”(在搜索框中输入 emmet 就足够了)

  4. Now you can enter the HTML you want to wrap your selected text with by entering emmet syntax.现在,您可以通过输入 emmet 语法来输入要包装所选文本的 HTML。 If you want to wrap it with a tag, just write the tag, in your example this would be b如果你想用标签包装它,只需写标签,在你的例子中这将是b

  5. You can also wrap your text with multiple Tags and also add classes and attributes to these tags, for example: a.more-link[title="test"][href="test.com"] would wrap your text with <a class="more-link" title="test" href="test.com">...your selected text... </a>您还可以使用多个标签包装您的文本,并为这些标签添加类和属性,例如: a.more-link[title="test"][href="test.com"]将使用<a class="more-link" title="test" href="test.com">...your selected text... </a>包装您的文本<a class="more-link" title="test" href="test.com">...your selected text... </a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM