在 Sublime Text 中查找结束 HTML 标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14814182/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:31:48  来源:igfitidea点击:

Find closing HTML tag in Sublime Text

htmlsublimetext

提问by Pavel Binar

I have a very long and very nested HTML document, where I need to quickly find the closing tag. How can I do this?

我有一个非常长且嵌套非常多的 HTML 文档,我需要在其中快速找到结束标记。我怎样才能做到这一点?

回答by Mikko Ohtamaa

Try Emmet plug-in command Go To Matching Pair:

试试 Emmet 插件命令Go To Matching Pair

http://docs.emmet.io/actions/go-to-pair/

http://docs.emmet.io/actions/go-to-pair/

Shortcut (Mac): Shift+ Control+ T

快捷方式(Mac):Shift+ Control+T

Shortcut (PC): Control+ Alt+ J

快捷键(PC):Control+ Alt+J

https://github.com/sergeche/emmet-sublime#available-actions

https://github.com/sergeche/emmet-sublime#available-actions

回答by jeffsama

There is a shortcut (Ctrl+Shift+Afor Windows and Linux users, Command+Shift+Afor Mac users) to select the whole block within the currently selected tag.

有一个快捷键(Ctrl+ Shift+ AWindows和Linux用户,Command+ Shift+ AMac用户)来选择当前选定的标签内的整个街区。

For example, if you pressed this while your text cursor was within the outer divtag in the code below, all the divs with class selectedwould be selected.

例如,如果您在文本光标位于div下面代码中的外部标记内时按下此按钮,则将选择所有div带有 class的s selected

<div class='current_tag_block'>
  <div class='selected'></div>
  <div class='selected'></div>
  <div class='selected'></div>
  <div class='selected'></div>
</div>

回答by K. Kilian Lindberg

It's built in from Sublime Editor 2 at least. Just press the following and it balances the HTML-tag

它至少是从 Sublime Editor 2 内置的。只需按以下,它就会平衡 HTML 标签

Shortcut (Mac): Shift+ Command+ A

快捷方式(Mac): Shift+ Command+ A

Shortcut (Windows): Control+ Alt+ A

键(Windows): Control+ Alt+ A

回答by Jeremy Ross

Under the "Goto" menu, Control+ Mis Jump to Matching Bracket. Works for parentheses as well.

在“转到”菜单下,Control+M是跳转到匹配括号。也适用于括号。

回答by wortwart

As said before, Control/Command+ Shift+ Agives you basic support for tag matching. Press it again to extend the match to the parent element. Press arrow left/right to jump to the start/end tag.

正如前面所说的,Control/ Command+ Shift+A为您提供了标签匹配的基本支持。再次按下它以将匹配扩展到父元素。按向左/向右箭头跳转到开始/结束标签。

Anyway, there is no built-in highlighting of matching tags. Emmet is a popular plugin but it's overkill for this purpose and can get in the way if you don't want Emmet-like editing. Bracket Highlighterseems to be a better choice for this use case.

无论如何,匹配标签没有内置突出显示。Emmet 是一个流行的插件,但它对于这个目的来说太过分了,如果你不想要类似 Emmet 的编辑,它可能会妨碍你。Bracket Highlighter似乎是这个用例的更好选择。

回答by Brandito

None of the above worked on Sublime Text 3 on Windows 10, Ctrl + Shift + ' with the Emmet Sublime Text 3 plugin works great and was the only working solution for me. Ctrl + Shift + T re-opens the last closed item and to my knowledge of Sublime, has done so since early builds of ST3 or late builds of ST2.

以上都不适用于 Windows 10 上的 Sublime Text 3,带有 Emmet Sublime Text 3 插件的 Ctrl + Shift + ' 效果很好,并且是我唯一可行的解​​决方案。Ctrl + Shift + T 重新打开最后一个关闭的项目,据我所知,自从 ST3 的早期版本或 ST2 的后期版本以来,就已经这样做了。

回答by WesternGun

I think, you may want to try another approach with folding enabled.

我认为,您可能想尝试另一种启用折叠的方法。

In both ST2 and ST3, if you enable folding in User settings:

在 ST2 和 ST3 中,如果您在用户设置中启用折叠:

{
    ...(previous item)
    "fold_buttons": true,
    ...(next item, thus the comma)
}

You can see the triangle folding button at the left side of the line where the start tag is. Click it to expand/fold. If you want to copy, fold and copy, you get all block.

您可以在开始标记所在行的左侧看到三角形折叠按钮。单击它以展开/折叠。如果你想复制,折叠和复制,你会得到所有的块。

enter image description here

在此处输入图片说明