Giter Site home page Giter Site logo

matchtag's Introduction

Readme

This plugin highlights the matching HTML tag when the cursor is positioned on a tag. It works in much the same way as the MatchParen plugin.

It was inspired by this question http://stackoverflow.com/q/8168320/20388.

The latest 'release' is available on vim.org.

Other file types

To get this to work for file types other than html that use a similar tag structure (e.g XML) you can do something similar to this.

echo 'runtime! ftplugin/html.vim' > ~/.vim/ftplugin/xml.vim

The xml.vim file demonstrated here is included with MatchTag.

Screenshot

Thanks to ithaca.arpinum.org for this screenshot.

Screenshot of MatchTag

matchtag's People

Contributors

0matgal0 avatar gishmel avatar gregsexton avatar inkarkat avatar mattsacks avatar twinside avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matchtag's Issues

Why MatchTag is consume resources on filetype=vim (maybe others too)?

I just notices that when Im moving across my custom colorsheme source, there is a huge lags during movements via jk. So I decided to profile what is currently happening and found that MatchTag is trying to match something on current filetype... Checked twice :set ft? so its really equals to vim.

Here is some statistic from profiles:

FUNCTION  <SNR>85_Highlight_Matching_Pair()
Called 85 times
Total time:   0.014041
Self time:   0.014041


389 FUNCTIONS SORTED ON TOTAL TIME
390 count  total (s)   self (s)  function
391    85   0.014041             <SNR>85_Highlight_Matching_Pair()
392    88   0.012402             airline#check_mode()
393    88   0.007818             airline#extensions#whitespace#check()
394   440   0.004540             airline#util#wrap()
395    88   0.004066             airline#statusline()
396   176   0.003881             airline#util#append()
397    88   0.003260             airline#parts#ffenc()
398    85   0.001647             <SNR>97_sync_active_winnr()
399    88   0.000984             airline#parts#iminsert()
400    88   0.000622             airline#parts#paste()
401    88   0.000597             airline#parts#mode()
402    88   0.000511             airline#parts#readonly()
403    88   0.000448             airline#parts#filetype()
404     1   0.000146   0.000129  unite#handlers#_on_cursor_hold()
405     1   0.000051             <SNR>137_garbage_collect()
406     1   0.000017             <SNR>144_restore_statusline()

As you can see, airline in pair with MatchTag crap a little performance.
How I can prevent MatchTag to load (e.g. use Highlight_Matching_Pair function)?

Can color be specifiled?

Hi,

Thanks for your plugin! That's really amazing!!
However, I want to know, how can I specified the color of matching tags?

Thanks.

Br. Marslo

Sometimes highlights wrong match

I have a file whose content is

<div><div></div><div></div></div>

When I place my cursor over the fifth tag, the first tag is highlighted as its "match". When I place my cursor on the last tag, no match is highlighted.

Plugin failure

vim: 8.1.173
plugin: latest

function 109_Highlight_Matching_Pair[20]..109_SearchForMatchingTag

E475: incorrect variable: 0

runt! html.vim may break other behavior

It is not safe to source html.vim for other file types.

For example,
In my ftplugin/ I have html.vim and xml.vim
html.vim:
map a b
xml.vim:
map a c
Without MatchTag, I can get right mapping (a->c) in xml, however with MatchTag, I get a->b for xml files, because html.vim is loaded after xml.vim.

We may have 2 solutions:

  1. use so <sfile>:p:h/html.vim instead of runtime in other file types.
  2. wrap everything in html.vim into a function and define autocmd in plugin/.

Thanks.

Is there any way to work with other file extensions?

i work with file extension *.html.twig where plugin is not working, how i can upgrade your plugin to make it work? i don't know vim language well, i looked inside "html.vim" and didn't found something that leads to extensions

Rename the scripts, as they are not core ftplugins.

Your useful plugin does not provide core ftplugin functionality (like setting 'iskeyword', 'wrap', etc.), but rather ancilliary functionality. Therefore, it should be renamed to html_matchtag.vim (and xml_matchtag.vim), and this guard dropped:

if exists("b:did_ftplugin")
    finish
endif

Otherwise, this prevents the default $VIMRUNTIME/ftplugin/html.vim from becoming effective.

Ignore single tags, e.g. <br />

Hi,

I just tested this plugin, and when I tried it on a random XML-file I discovered that it had a minor issue that I think should be relatively easy to fix. Consider the following xml-code:

  <property name="&lt;Super&gt;p" type="empty"/>
  <property name="&lt;Control&gt;Escape" type="empty"/>
</property>

In this case, when the cursor is on the second "property" tag, it should not match the -tag. However, it does, since it does not recognize the closing "/>" as making the tag a "single tag".

Customize colors

Hi, it would be great if you could configure the highlight colors. The defaults don't blend very well with solarized light.

Pathogen incompatibility due to folder name

Pathogen only finds plugins if the .vim files are in a folder called plugin. Because it's called ftplugin instead, pathogen doesn't not automatically install the plugin.

If there's no reason to call it ftplugin, changing it to plugin would decrease friction for users.

Please upload a newer version to vim.org.

I've been using version 1.2 (2011-11-21) from vim.org, noticed and fixed the bug with <tagname/> highlighting. Just when I wanted to submit the patch to you, I realized that you had already fixed this in your repo.

Please publish a new version to vim.org; not everyone is following your repo!

Neovim Support?

Does the plugin have support for neovim and vim-plug? I'm a newbie in vim so if it supports neovim, where should I drop the HTML file?

plugin doesn't highlights if tags are spread on multiple lines

screenshot at 2013-07-14 14 13 56
Note that <activity> tag starts at line 7.

image
if I make the remaining part of the starting tag from line 8 to line 7, the tag is highlighted as expected.

I am trying to say that it would be helpful if plugin is made to recognize the tag even if it spread on multiple lines.

What do you think of this?

No smarty template file support

Greetings,

Great plugin, however I am constantly editing smarty template files which (ft=smarty) which there is no support for.

I have attempted copying the xml.vim to tpl.vim (file extension is .tpl) but it appears the matching algorithm breaks when curly braces are present.

Thanks.

Gez

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.