跳转到 Vim 中匹配的 XML 标签 [英] Jump to matching XML tags in Vim

查看:33
本文介绍了跳转到 Vim 中匹配的 XML 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Vim % 操作符跳转到匹配的括号、注释结束和其他一些东西.但是,它不匹配 XML 标签(或任何其他标签,据我所知).

Vim % operator jumps to matching parentheses, comment ends and a few other things. It doesn't, however, match XML tags (or any other tag, to the best of my knowledge).

使用 Vim 跳转到匹配的 XML 标签的最佳方法是什么?

What's the best way to jump to the matching XML tag using Vim?

注意:真正想做的是在不手动查找匹配标签的情况下复制 XML 文件中的一个部分.

Note: What I really want to do is duplicate a section in an XML file without manually looking for the matching tag.

推荐答案

有一个名为 matchit.vim 的 vim 插件.你可以在这里找到它:http://www.vim.org/scripts/script.php?script_id=39 .它的创建目的与您描述的完全相同.

There is a vim plugin called matchit.vim . You can find it here: http://www.vim.org/scripts/script.php?script_id=39 . It was created pretty much the exact purpose you describe.

安装它,将光标放在标签的主体上(不是 <>,否则它会匹配那些),然后按 % 跳转到另一个标签.查看脚本页面以了解它匹配的其他内容.

Install that, place your cursor on the body of the tag (not the <>, else it'll match those) and press % to jump to the other tag. See the script's page to find out what else it matches.

这篇关于跳转到 Vim 中匹配的 XML 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆