vim能否突出显示匹配的HTML标记,如Notepad ++? [英] Can vim highlight matching HTML tags like Notepad++?

查看:148
本文介绍了vim能否突出显示匹配的HTML标记,如Notepad ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VIM支持匹配大括号,括号和方括号对。这对于编辑PHP和Javascript等C风格语言非常有用。但是匹配HTML标签呢?



Notepad ++只要我一直使用它就有这个功能。能够发现HTML块的开始和结束是非常有用的。我正在寻找的是类似vim的东西(请参阅绿色div标签):



(奖励功能:突出显示未封闭的HTML标签,如截图中的红色标签)。已提出b
$ b

matchit 作为下一个最好的事情,但它需要额外的击键才能使用它的功能。我希望能够看到HTML块的开始和结束位置,而不需要额外的按键。



我已经浏览了互联网,为vim找到这样的东西。显然,根据其他两个 StackOverflow ,我不是唯一一个< a href =https://stackoverflow.com/questions/1957083/vim-script-to-hightlight-end-of-a-tag-like-braces/1960175>问题和 nabble



我已经几乎辞职了vim无法在视觉上匹配html标签。 vim可以做到这一点吗?



附录:如果目前无法对任何现有的插件进行此操作,那么任何vimscript向导都会有指针如何编写合适的插件?

解决方案

今天我不得不使用一些HTML,所以我想解决这个问题。



你可以在vim.org上找到它



你可以在github上得到它。



希望它适合你。如果您有任何问题,请告知我。


VIM has support for matching pairs of curly brackets, parentheses, and square brackets. This is great for editing C-style languages like PHP and Javascript. But what about matching HTML tags?

Notepad++ has had this feature for as long as I've been using it. Being able to spot where blocks of HTML begin and end is very useful. What I'm looking for is something like this for vim (see the green div tags):

(a bonus feature: highlighting unclosed HTML tags, like the red tag in this screenshot).

matchit has been proposed as a next-best-thing, but it requires an extra keystroke to use its functionality. I'd like be able to see where the blocks of HTML begin and end without an extra keypress.

I've trawled the internet to find something like this for vim. Apparently, I'm not the only one, according to 2 other StackOverflow questions and nabble.

I've almost resigned myself to vim not being able to visually match html tags. Is it possible for vim to do this?

Addendum: If it is not currently possible to do this with any existing plugins, does any vimscript wizard out there have any pointers on how to approach writing a suitable plugin?

解决方案

I had to work with some HTML today so thought I would tackle this. Added a ftplugin to vim.org that should solve your problem.

You can get it here on vim.org.

You can get it here on github.

Hope it works for you. Let me know if you have any problems.

这篇关于vim能否突出显示匹配的HTML标记,如Notepad ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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