What's the best shortcut or plugin to comment out HTML/XML elements?
And also need to uncomment.
You can use a combination of matching XML tags, as can be seen in this question and Perl's search and replace.
For instance, given this snippet:
<TypeDef name="a">
<ArrayType high="14" low="0">
<UndefType type="node">
</UndefType>
</ArrayType>
</TypeDef>
Put the cursor on either the opening or closing TypeDef and type the following sequence:
vat:s/^\(.*\)$/<!-- \1 -->/
v
- puts you into visual mode at
- selects the whole XML tag :s/^\\(.*\\)$/<!-- \\1 -->/
- surrounds each line with '<!-- ... -->'
, the comment delimiters for XML Alternatively, you can just delete it like this:
dat
d
- delete according to the following movements at
- as before To delete id use then use vat:s/-->//
to delete comments
如果您使用emmet-vim ,则可以通过按vat
选择要注释掉的标签的全部内容,然后按Ctrl y /
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.